Short:
Step1: Created a product by hand and exported it as csv file.
Step2: Deleted the product, so the Database is empty again.
Step3: Uploaded the images
Step4: Imported the csv file
[base|small|thumbnail|swatch]_image are working.
additional_images is empty and throwing this error:
Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in rows: ...
Long:
I've created a product by hand and exported it as CSV. I used that CSV file as pattern and added all the products.
I also uploaded the images in pub/media/import. I've put the first image as base_image small_image etc. and put every image again into the 'additional_images' column.
When pressing import (with correct image path entered) it finds all the images and copies them to pub/media/catalog/product. However it reports the following:
Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in rows: ...
Now comes the weird part: the base, small etc images are working. So the overview in frontend and backend are both having images. When editing the product, the gallery is empty. When entering the product detail-page, the images are missing.
When exporting the products again the base, small etc fields are correctly set, additional_images are empty. So something musts be broken with that field regarding the import feature.
I would fix it by myself but have no single clue where to start looking for that. So if anyone has a hint or maybe even a fix for this, i would be very thankful.
(Before anyone asks, got the same problem when importing the exported csv without adding further products)
After a lot of digging i just found out that the images are correctly added to catalog_product_entity_media_gallery
table but NOT to catalog_product_entity_media_gallery_value
and catalog_product_entity_media_gallery_value_to_entity
. Manualy adding those makes the images appear everywhere correctly. So the bug is simple: the relations between the images and the products will not be stored on csv import!
Is there any update on this issue yet? Any work arounds? Even a temp core hack to get product images in place would be great.
After some digging I came up with a solution. It seems the issue with permissions error is related to the local file system only and not remote systems. When running the import and pulling off from http://domain.com/pub/media/import/image.jpg it works when the same files error out with only /pub/media/import/image.jpg
Hope this helps someone.
I managed to get around this after switching to PHP 7, did not manage to get around this on 5.6 - Runs perfectly on PHP7 in my case.
I'm having the same problem when I try to import an image from a remote URL
+1 Same issue here. Tried manually specifying a path like var/import_media
tried specifying pub/media/import
and leaving it blank. Any ideas?
Hello Icereaper, I updated to PHP7 but I still don't see any images. So I have the same problem as described above : the base, small etc images are working. So the overview in frontend and backend are both having images. When editing the product, the gallery is empty. When entering the product detail-page, the images are missing.
How did you manage to work around and import the image if i may ask? Thx
Having same problem. Any update?
As said, nothing ever worked, but then i tried to set the php version to 7.0 in the cpanel, and suddenly it worked. The switch to php 7.0 will have caused a different php.ini and extensions to be loaded, so it might be a php related setting.
Please, provide the used version. If the problem is actual for a specific branch, please, specify it and be sure that the latest update was used.
It's still not working in 2.1.0 GA
I can confirm that.
Still not working in 2.1.0
PHP 5.6.22 (cli) (built: May 26 2016 14:22:49)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with XCache v3.2.0, Copyright (c) 2005-2014, by mOo
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.3.3, Copyright (c) 2002-2015, by Derick Rethans
with XCache Optimizer v3.2.0, Copyright (c) 2005-2014, by mOo
with XCache Cacher v3.2.0, Copyright (c) 2005-2014, by mOo
with XCache Coverager v3.2.0, Copyright (c) 2005-2014, by mOo
It seems it should not import cvs file from the template being exported directly.
I am changing the value for all images from "/i/m/image.png" to be 'image.png' in the exported template csv file.
and place the uploading images in directory "/your_magento2_root/var/import/", then configure "Images File Directory" with relative path "var/import".
This is working for me.
I am getting the same error message when i tried to import images from AWS.
Posting here in case someone experiences the same issue in the future.
After some digging, looks like it is failing because the my image links where containing a parameter
ex. ?1415800484
As a result on media/import the image names where like that:
and the Import was breaking.
@vzabaznov Facing the same issue.
PHP 5.6.23 (cli) (built: Jun 26 2016 13:17:47)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
Cent-OS 6 on aws
I have fixed it by running the below on magento root directory ...
Looks like the group or the user of apache/nginx does not have the permission to write on pub/media/catalog/product even if you don't have it on pub it will not allow you to write.
find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \;
find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \;
@magento-team
if you can add a log along with return false in the below function resides in
vendor/magento/module-catalog-import-export/Model/Import/Product.php
will help the developers to easily identify the issue.
protected function uploadMediaFiles($fileName, $renameFileOff = false)
{
try {
$res = $this->_getUploader()->move($fileName, $renameFileOff);
return $res['file'];
} catch (\Exception $e) {
$this->_logger->critical($e); // Added by senthil_m
return '';
}
}
My issue was resolved by ensuring all the URL's fetched from remote servers were properly URL encoded in my CSV.
In particular, the remote URL filenames had spaces in them. If you were to replace all space characters with %20, you'll be fine.
Hope that helps anybody else in the same boat as I was.
receiving same message but for all images when importing from cvs file with images in pub/media/import folder.
Not sure if this has anything to do with your issue as this is an internal import but I realized the CVS files should have no file path for the images. It should just be the image name.
In M2 I have images stored in pub/media/import but would get the same error 1. Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in row(s): 1, 2
I removed the path name from my CSV file and just have the image path as image.jpg with no slashes and it works great now.
Can confirm that rosandrest's solution works, removing the external links altogether helped with 2.1
@veloraven
I got the error mentioned as _"Imported resource (image) could not be downloaded from external resource due to timeout or access permissions"_ when I used following format of csv file to import image in Magento 2.0.0 version(Windows 10).
The format of csv which I used was as following >>
sku,base_image,errors
WT09-XS-Purple,/pub/media/import/wt09-white_back-test.jpg
and under the File to import section's sub section _Images File Directory_ I used the path as _/pub/media/import_
I had the image to be imported at _pub/media/import_ location
The problem solved when I used following csv format :
"sku","base_image"
"WT09-XS-Purple","wt09-white_back-test.jpg"
and _Images File Directory_ value as _pub/media/import_
I think there needs to be some updates on following devdocs page:
http://docs.magento.com/m2/ce/user_guide/system/data-import-product-images.html
Mage Version 2.1.1 - Production Mode (running from pub/index.php) - PHP 5.6.21 (php-fpm/lighttpd)
We were seeing remote files download to pub/media/import
but failing to move over to pub/media/catalog
.
I hunted back to the source exception (Magento\Framework\File\Uploader::_createDestinationFolder()
) and dumped it out;
string(113) "Unable to create directory 'pub/media/catalog/product'."
Checked to be sure that path was correct by adding in getcwd()
before $destinationFolder
in the exception.
string(113) "Unable to create directory '/data/www/site/xxx/release-160912.0703/pub/pub/media/catalog/product'."
pub/pub.. that's never going to work..
Tracing this back;
vendor/magento/module-catalog-import-export/Model/Import/Product.php
within _getUploader()
$dirConfig = DirectoryList::getDefaultConfig();
$dirAddon = $dirConfig[DirectoryList::MEDIA][DirectoryList::PATH];
In this scenario.. $dirAddon
is string(9) "pub/media"
Given we're running from pub/index.php
, and getDefaultConfig()
returns relative urls, this will never work.
Catalog import/export seems to be the only real function that calls DirectoryList::getDefaultConfig()
, so I'm assuming it's some kind of oversight.
I don't have a good solution for this - otherwise I'd throw in a patch.
[Edit]
Just realised this is a different issue to the OP, but the conversation thread is most likely related to the above
Hi,
So Im experiencing an issue with relation to the above.
Now, I do not believe this to be an error with regards to permissions as I have been able to upload 1000's of images using the same import file structure no issues.
I have attached a sample file with 3 rows.
Row 1 is fine and imports
Row 2 has a mixture of good images and images from a website that file.
Row 3 has images from a site that always fails.
Further to this I went into a product record and tried to use the remote url as the path and this worked.. I used the urls from the failed lines.
Example Steps:
Here I go into any product and use the same url that failed via the import routine.
This saved successfully
Also see attached sample file. Please note sample file uses the "^" as the field delimeter.
What do I think it is??
Perhaps a timeout setting with curl? Or whatever is used to control the fetching of images from remote sites. I think this setting is perhaps too low and thus times out too early to complete the download.
I did a quick hunt around and can see curl is used and can see the following:
curlopt_connecttimeout
but it uses settings from getConfig
Which I cannot find where these are located
Regards
Brendan
Magento 2.1.0
PHP 5.6.23
Having the same issue Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in row(s):
I tried the following [nothing worked so far]:
The service user has full control over Magento2 home and sub-directories in fact pub/ permissions are 777
Help!
Update 121616
No luck! I found a suggestion which instructs creation of a separate csv file with only containing sku and image & image label columns (base_image, base_image name, thumbnail_image, thumbnail_image name etc.). Tried import, same error
The I created a sub directory under /pub/media/import called myfiles. In csv file, changed base_image value from image.jpg to myfiles/image.jpg. Same error.
Tried putting a forward slash / before image name e.g. /imagefile.jpg in csv file, Same error.
I looked into Product.php Magento_Root/public_html/vendor/magento/module-catalog-import-export/Model/Import for error message and found it's definition at line 263
263 ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE => 'Imported resource (image) could not be downloaded from external resource due to timeout or access permissions',
and it's use in upload function on line 1558.
Looks like whoever described the error message has not put helpful information in that which has made it misleading. Anyway, I changed the original error message as such that it looks something that can be seen in attachment.
The point is, it is not possible to really see what is causing the failure in the background.
It's skull cracking...
configurable products are not displaying ..i am using this cvs file
Book2.xlsx
Same issue here.
PHP7 and Magento 2.1.2
Someone knows how to fix this?
As yet, I have seen no way to resolve this issue.
Based on how long is been open 12 months and counting, its obviously not a priority to magento devs to resolve.
Hope you're wrong, it's quite a priority for me! :( @brendanbell
Same issue here.. Permissions and filepaths are OK. Checking the data works, but importing fails for the images. Magento 2.1.2. I'm using slashes/subdirectories in my image paths
If I recall correctly, the issue is one of not showing enough detail in the error. Here is what I did to fix (and I thought I posted here but apparently didn't).
I'll post line numbers and such when I get a chance. May turn into a pull request
@AddoSolutions , thanks for your reply. Your message caused me to dig deeper and output the Exception message. I'm not sure whether it was the difference between /pub/media/import
or pub/media/import
, permissions that for some reason weren't set correctly on media/product/catalog
, or the pub
to pub
symlink suggested here: https://github.com/magento/magento2/issues/5359, but I finally got it to work.
I added a throw $e
in vendor/magento/module-catalog-import-export/Model/Import/Product.php
on line 1866 (I believe) to get better reporting. It's pretty bad it just swallows the exception and returns an empty string.
Yup, that sounds familiar! I'll poke around to see if there is a way to add the actual exception message to the useless one.
Hi @veloraven
Is there any update on this issue from Magento core team. This is open since last year.
OK the solution to this problem is so stupid simple that anyone reading this and spending more than 1 hr will be kicking themselves.
Problem: When importing images from a remote server get error "Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in rows: ..."
Solution: Make sure that the folder you are importing the images exists currently, and if not you must create it manually via ftp or cpanel.
i.e: in this situation the folder to which the images should be uploaded is "pub/media/import" this folder "import" does not exist by default on Magento2, and must be created in order for files to be uploaded there.
If you are importing files from your same server, import it as "example.png" vs "pub/media/import/example.png" if you are using "pub/media/import" as your uploading directory.
This is one solution for this error, so there may be multiple reasons this error is showing, that being said this solution worked for me
.. Again, the error should be updated to be more specific I agree
GL to all, hope this helps
Hi,
Was just thinking, is it possible to expose the full error message. As I understand it, in some cases magento "truncates" error messages.
If we could stop the error truncation, we may be able to see what each underlying error really is.
Regards
Brendan
Hi,
Try this:
Go to
ln -s ./ pub
It's work for me.
Cheers,
Dawid
We had the exact same problem as explained here, but for us this had nothing to do with permissions or incorrect filepaths.
Using the suggestion from @senthilengg by logging the exception in the 'uploadMediaFiles' function, we came to the conclusion that our client had uploaded corrupt .jpg files.
In Magento\Framework\Image\Adapter\AbstractAdapter an exception was thrown in the 'validateUploadFile' function which caused the import to fail.
I think this issue can be closed as it is not Magento who is causing this issue.
The actual problems are caused by manual actions (ie. setting incorrect permissions, using faulty images, etc. ...). However, I do agree that logging and output are lacking quite a bit. Users could more easily spot their problems if the output was more accurate and closer to the actual problem.
@bacd there is internal ticket MAGETWO-58227 for your issue. This bug was fixed in 2.2 (branch 'develop')
@IceReaper, @davidnguyen2205, @davidnguyen2205, @Ctucker9233, @yssource, @St0iK, @brendanbell if this issue is actual for you try to import images on Magento v2.2.0.
It should work now. I can provide more details if somebody needs.
Hi @TomashKhamlai,
Is there a backport to 2.1.x planned for this fix?
If not, I'd suggest marking the issue with the up for grabs
label so that someone from the community could notice it and consider putting some effort into a PR backporting the relevant commits (these are the ones, I assume) into 2.1-develop
branch.
hi @TomashKhamlai !
thanks for your clarification. Unfortunately we've been experiencing it in a fresh 2.2.0 too. It imports just 1 product (with its own images) then fails after that with the same error reported above (products' images placed in same local server in pub/media/import).
following the many suggestions above didn't lead to a solution.
could you please provide a hint?
thanks!
edited: in my case turned out to be an issue probably reported in #10209 Magento 2 import products with images using CSV Issue
Hello @romeof1980! You should be able to perform import on Magento 2.2.0. I think that you have problems in Step 5 of the instruction.
Instruction:
sudo su magento
in my case). On Ubuntu 'magento' user is a member of the 'www-data' group. On CentOS 'magento' user is a member of 'apache' group. How to check this:magento@TSG-215:/var/www/html/third$ groups ${whoami}
magento www-data
More information here: #mage-owner-about-group
/var/www/html/third
in my case)mkdir -p var/import
pub/media/catalog/product
after the product export. Here is what I've created.magento@TSG-215:/var/www/html/third$ tree var/import
var/import
└── t
└── -
├── t-shirt-mo-prob-lama_1.jpg
├── t-shirt-mo-prob-lama-back_1.jpg
├── t-shirt-mo-prob-lama-gallery_1.jpg
└── t-shirt-mo-prob-lama-normal_1.jpg
2 directories, 4 files
I attached zip file with images t.zip. You can copy it by FTP to var/import
folder and then unzip it.
magento@TSG-215:/var/www/html/third/var/import$ ls
t.zip
magento@TSG-215:/var/www/html/third/var/import$ unzip t.zip -d .
Archive: t.zip
creating: ./t/
creating: ./t/-/
inflating: ./t/-/t-shirt-mo-prob-lama-gallery_1.jpg
inflating: ./t/-/t-shirt-mo-prob-lama-normal_1.jpg
inflating: ./t/-/t-shirt-mo-prob-lama-back_1.jpg
inflating: ./t/-/t-shirt-mo-prob-lama_1.jpg
magento@TSG-215:/var/www/html/third/var/import$ ls
t t.zip
find var/import -type f -exec chmod g+w {} \; && find var/import -type d -exec chmod g+ws {} \; && chown -R magento:www-data var/import
Expected result:
Hello again. @romeof1980, I changed my mind. Pay more attention to step 2, and even much more to step 6.
Try to perform import without folder structure, but modify CSV. You need to edit the relative path to image files:
/t/-/t-shirt-mo-prob-lama-gallery_1.jpg => /t-shirt-mo-prob-lama-gallery_1.jpg
Images should be placed in var/import folder.
I was getting the same error, i fixed this. The solution was to have no spacial charechter, no space in the image file names. only alphabets and numbers. And it worked for me.
so by summarising all the solutions I've seen here and in other places, I did the following:
'Image-Name.jpg' > md5('Image-Name') . 'jpg'
chown www-data:www-data pub/media/import/*
chmod 0755 pub/media/import/*.jpg
as a result - everything worked
PS if you following then do not forget to change image filenames to md5('Image-Name') . 'jpg'
in your csv file
@site-me i have to say this is a dumb thing that most of us don't think about when uploading images.
I was banging my head for about an hour before finding this and realizing how easy it was.
@site-me
Thanks a lot for the solution, i was stuck with this stupid image issue for over a week.
Can u just clarify one more doubt of mine, when u said remove all alnum characters do u mean no special characters also i mean like can we not use a "-" or "_" in the image name?
@WindiceDev
I’ve noticed some recommendations about naming files which reported by several people as helpful, so I included this in my solution. Yes I left only numbers an letters in the file names (and an extension of course) by applying hash function which gives you exactly this set of characters
I am facing the same issue in Magento 2.3.1, To fix this I have follow the below steps:-
var/import
instead of /pub/media/import
import
name, Set the full permission of var folder including import
folder.Hope that helps you
I encountered this problem too and i was able to solve it with the following steps:
Uploaded product images into /pub/media/import
In my CSV i used http://www.domain.com/pub/media/import/image_name.jpg
without specifying the folder to upload to.
Hope this will help whosoever facing the same problem.
Your image name should not have space or any special character to make it upload
I realize this post is closed, but I wanted to add an update related to Magento ver. 2.3.2. I was running into this same error when uploading a csv that pulling a single image from an external url with no special characters or url related issues.
Imported resource (image) could not be downloaded from external resource due to timeout or access permissions
A quick check of the exception.log and I saw this:
[2019-11-20 23:59:35] main.CRITICAL: File directory 'pub/media/import' is not readable.
In my scenario, it was due to the pub/media/import directory missing completely. So, even if you are downloading a file from an external url, Magento uses the import directory to stage the file. Good to know.
Not sure if this has anything to do with your issue as this is an internal import but I realized the CVS files should have no file path for the images. It should just be the image name.
In M2 I have images stored in pub/media/import but would get the same error 1. Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in row(s): 1, 2
I removed the path name from my CSV file and just have the image path as image.jpg with no slashes and it works great now.
THanks, problem solved
In Magento2.3.3 CE there is no need to specify the path. Just paste product images at
I am using Magento 2.3.2 version and tried a lot to import products but best solution I found
put your all images at pub/media/images/catalog/product/CUSTOM_DIR/1.jpg
eg: /var/www/html/ocean-tableware/pub/media/catalog/product/lucaris
In csv put base_image path as /CUSTOM_DIR/1.jpg
/lucaris/1.png
While import from backend put path 'pub/media/import/
For more you can check here https://magento.stackexchange.com/a/325213/82482
Most helpful comment
I have fixed it by running the below on magento root directory ...
Looks like the group or the user of apache/nginx does not have the permission to write on pub/media/catalog/product even if you don't have it on pub it will not allow you to write.
find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \;
find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \;
@magento-team
if you can add a log along with return false in the below function resides in
will help the developers to easily identify the issue.