S3-Uploads icon indicating copy to clipboard operation
S3-Uploads copied to clipboard

Media library error, Unable to create directory uploads/2020/10. Is its parent directory writable by the server?

Open VitaTamry opened this issue 4 years ago • 4 comments

I know this issue has been raised before but still cannot find a fix for it.

server | nginx/1.10.3 PHP version | 7.3.23 cURL version | 7.52.1 OpenSSL/1.0.2u WordPress | 5.5.1

php.ini allow_url_fopen = On

  • the commands wp> wp_upload_dir(); wp> file_put_contents( wp_upload_dir()['basedir'] . '/2020/10/test.txt', 'test' ); are working fine and I can upload from wp shell.

  • I also uploaded the uploads folder directly to S3 and the plugin successfully rewrites the paths and they show up in the media library except I cannot make an edit on any of them.

VitaTamry avatar Oct 28 '20 16:10 VitaTamry

Trying to solve this here as well #420 and #456

I think it is specifically related to the S3 stream wrapper, but I just don't know how to debug that. For me the command line works as well, but when in the admin media library it doesn't work.

natereist avatar Oct 28 '20 19:10 natereist

My issue might be unrelated, but I just spent a few hours struggling with this exact issue. It turned out that allow_url_fopen was actually disabled because it was using a different config file than the one I expected. I would try temporarily adding var_dump(ini_get('allow_url_fopen')); right at the location where you're testing the file operations to be sure it's actually enabled at the moment the code is running.

zookatron avatar Dec 05 '20 00:12 zookatron

@zookatron allow_url_fopen is set to On and still giving the same error

VitaTamry avatar Feb 03 '21 15:02 VitaTamry

If it helps anyone, I found it really does need allow_url_fopen = on

And in my case, I needed this:

add_filter('s3_uploads_s3_client_params', function ($params) {
    $params['use_aws_shared_config_files'] = false;
    return $params;
});

I have some base_dir restrictions in PHP and AWS SDK tries to look into the home user folder for the .aws/config files, which is blocked in my case. So having the filter above solves it.

andrefelipe avatar Nov 10 '21 19:11 andrefelipe