Open garubi opened 2 years ago
Note that your configuration should be
define( 'S3_UPLOADS_USE_LOCAL', true );
(No quotes around the true value.)
fopen('', 'wb')
seems suspicious, and would indicate you're hitting this conditional:
That is, I suspect realpath()
is returning false
as your upload directory potentially doesn't exist or can't be created.
My guess would be that this is a permissions issue with PHP not being able to write to either the uploads directory, or create the subdirectory within it.
@rmccue thanks for your reply.
I corrected this: define( 'S3_UPLOADS_USE_LOCAL', true );
don't know why I put it in quotes, but this doesn't changed the problem.
I performed some more checks and I discovered that the wrapper can successfully create the uploads folders and subfolders, but it can't upload/write the files: the folders are empty.
About your suggestion that realpath()
fails I think I can confirm it: in debug.log
I have:
[18-Jul-2022 08:29:07 UTC] PHP Fatal error: Uncaught ValueError: Path cannot be empty in C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-content\plugins\S3-uploader-manual-install\inc\class-local-stream-wrapper.php:177
Stack trace:
#0 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-content\plugins\S3-uploader-manual-install\inc\class-local-stream-wrapper.php(177): fopen('', 'wb')
#1 [internal function]: S3_Uploads\Local_Stream_Wrapper->stream_open('s3://pandora-de...', 'wb', 0, NULL)
#2 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-admin\includes\file.php(983): move_uploaded_file('C:\\Users\\Stefan...', 's3://pandora-de...')
#3 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-admin\includes\file.php(1074): _wp_handle_upload(Array, Array, NULL, 'wp_handle_uploa...')
#4 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-includes\rest-api\endpoints\class-wp-rest-attachments-controller.php(1228): wp_handle_upload(Array, Array)
#5 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-includes\rest-api\endpoints\class-wp-rest-attachments-controller.php(240): WP_REST_Attachments_Controller->upload_from_file(Array, Array)
#6 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-includes\rest-api\endpoints\class-wp-rest-attachments-controller.php(158): WP_REST_Attachments_Controller->insert_attachment(Object(WP_REST_Request))
#7 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-includes\rest-api\class-wp-rest-server.php(1143): WP_REST_Attachments_Controller->create_item(Object(WP_REST_Request))
#8 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-includes\rest-api\class-wp-rest-server.php(990): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wp/v2/media', Array, NULL)
#9 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-includes\rest-api\class-wp-rest-server.php(414): WP_REST_Server->dispatch(Object(WP_REST_Request))
#10 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-includes\rest-api.php(394): WP_REST_Server->serve_request('/wp/v2/media')
#11 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-includes\class-wp-hook.php(307): rest_api_loaded(Object(WP))
#12 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-includes\class-wp-hook.php(331): WP_Hook->apply_filters('', Array)
#13 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-includes\plugin.php(524): WP_Hook->do_action(Array)
#14 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-includes\class-wp.php(398): do_action_ref_array('parse_request', Array)
#15 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-includes\class-wp.php(770): WP->parse_request('')
#16 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-includes\functions.php(1330): WP->main('')
#17 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-blog-header.php(16): wp()
#18 C:\Users\Stefano Garuti\Local Sites\bcok\app\public\index.php(17): require('C:\\Users\\Stefan...')
#19 {main}
thrown in C:\Users\Stefano Garuti\Local Sites\bcok\app\public\wp-content\plugins\S3-uploader-manual-install\inc\class-local-stream-wrapper.php on line 177
S3-Uploads ver 3.0.4 installed using manual-install.zip
I'm in local development (using Local by Flywheel 6.4.1, Ngnix, Php 8.0.0 on Windows )
I added in wp-config.php the row
define( 'S3_UPLOADS_USE_LOCAL', "true" );
The uploads fail with the error:
Unable to create directory uploads/2022/07. Is its parent directory writable by the server?
I verified to have
allow_url_fopen = On
Being on Windows it's unlikely that's really a permission issue... Maybe the local wrapper fails?
Tryed also with WP-CLI
wp s3-uploads verify
but failed with a fatal error: