[Product_Picture_Mapping] ISSUE

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Hi
When i try to upload excel product import. Sometime it doesn't add entry in [Product_Picture_Mapping] database ?
So i am loosing pictures for some products ?

But if i add picture from product edit from Admin. It work's. But i can't do one by one for more than 1000 products.

Please can you help me why this issue ?

Kind Regards
Manish
4 years ago
Well there is the media setting - Maximum image size which I assume can block the upload
See https://admin-demo.nopcommerce.com/Admin/Setting/Media
But there is no bug as such that would cause the issue

Do you get any errors logged ?

Do the pictures that are missing have any special characteristic
I.e are they bigger ? Have different security ?

I have found sometimes images have an internal problem and will not upload via admin
If you can work out which product has the problem you try to re-import just these products
4 years ago
Hi Yidna,
I have upload 1838 products but upload only 1335 images
i can see 1335 records in picture mapping table.
i can see 1838  records In picture table
i can see 1838  records in picture binary table.

All my image file start with number format and end with number format like 1245245.jpg
No idea what happen.
4 years ago
Hi
please see below when i try to import bulk product. some image failed

Log level  
Error
Short message  
Insert picture failed (file name: )
Full message  
System.NotSupportedException: Image cannot be loaded. Available decoders:
- BMP : BmpDecoder
- GIF : GifDecoder
- PNG : PngDecoder
- JPEG : JpegDecoder

   at SixLabors.ImageSharp.Image.Load[TPixel](Configuration config, Stream stream, IImageFormat& format)
   at SixLabors.ImageSharp.Image.Load[TPixel](Configuration config, Byte[] data, IImageFormat& format)
   at Nop.Services.Media.PictureService.ValidatePicture(Byte[] pictureBinary, String mimeType) in C:\andrei\nopcommerce\sources\src\Libraries\Nop.Services\Media\PictureService.cs:line 985
   at Nop.Services.Media.PictureService.InsertPicture(Byte[] pictureBinary, String mimeType, String seoFilename, String altAttribute, String titleAttribute, Boolean isNew, Boolean validateBinary) in C:\andrei\nopcommerce\sources\src\Libraries\Nop.Services\Media\PictureService.cs:line 762
   at Nop.Services.ExportImport.ImportManager.ImportProductImagesUsingHash(IList`1 productPictureMetadata, IList`1 allProductsBySku) in C:\andrei\nopcommerce\sources\src\Libraries\Nop.Services\ExportImport\ImportManager.cs:line 391
3 years ago
I have the same problem and the reason is pretty bizarre.
I just renamed:
0000127_picture-name.jpeg -> picture-name.jpeg

and here is the command line for multiple changing names:


cmd /V:ON /s /c "set "suffix=*_" && set "ext=jpeg" && for /F "delims=" %F in ('dir /B "!suffix!*.!ext!"') do @(set "_tmp=%F" && cmd /s /c "rename "%_tmp%" "%_tmp:!suffix!=%"")"


Just change ext to appropriate extension.

Have a nice day ...
3 years ago
I've been struggling with this issue as well and I think it's caused by a .NET bug. https://github.com/dotnet/runtime/issues/21626
The Uri.IsWellFormedUriString function sometimes returns a false negative depending on the characters in the URI. In my case some image file names had the ^ character in it.
The workaround I am using is to url encode the image string before checking if it is a valid uri. I also had to change uri kind from Absolute to RelativeOrAbsolute for it to work.

In the Nop.Services/ExportImport/ImportManager.cs file I changed the function DownloadFile as follows:

Before:
if (!Uri.IsWellFormedUriString(urlString, UriKind.Absolute))
  return urlString;

After:
var encodedUrl = System.Web.HttpUtility.UrlEncode(urlString);
if (!Uri.IsWellFormedUriString(encodedUrl, UriKind.RelativeOrAbsolute))
  return urlString;
3 years ago
Linden wrote:
I've been struggling with this issue as well and I think it's caused by a .NET bug.


Thanks for your investigation and suggestion to fix. Here is a work item.
3 years ago
Hi, Linden. We analyzed the problem and your solution, unfortunately this is really a problem in .Net, but your solution is not very suitable, since it actually disables the check completely. For example, your code will accept such a string as a valid address: "this is not a valid URL adress://tes.jpg"

Linden wrote:

The workaround I am using is to url encode the image string before checking if it is a valid uri. I also had to change uri kind from Absolute to RelativeOrAbsolute for it to work.

In the Nop.Services/ExportImport/ImportManager.cs file I changed the function DownloadFile as follows:

Before:
if (!Uri.IsWellFormedUriString(urlString, UriKind.Absolute))
  return urlString;

After:
var encodedUrl = System.Web.HttpUtility.UrlEncode(urlString);
if (!Uri.IsWellFormedUriString(encodedUrl, UriKind.RelativeOrAbsolute))
  return urlString;
3 years ago
Thanks. That's good to know. Maybe NopCommerce needs it's own uri validation until the. NET bug is fixed.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.