When creating a URI for a file, the S3 module (and upstream SDK) requires a bucket to be specified in the path. Unfortunately, core doesn't have a built-in way to hook into when URLs are created, and most contrib modules just generate string paths based on the scheme.
#2479523: Add a hook_file_stream_wrapper_uri_normalize_alter() hook adds an alter hook to file_stream_wrapper_uri_normalize(), which the S3 module implements to insert the bucket into the URI. For example, s3://image.jpg would be changed to s3://my-bucket-name/image.jpg.
For this to work, contrib modules need to normalize manually generated URIs. Since core's built-in function just resolves dots and slashes, it doesn't have any effect for sites not using S3 or not implementing the alter hook patch.
With this patch and the core alter hook patch above, if you set your default file system to S3, you can use IMCE to manage it.
This goes most of the way towards resolving #2502601: IMCE File browser in CK editor throws error over in the S3 queue.
Comment | File | Size | Author |
---|---|---|---|
#1 | 2530388.1-normalize-uri.patch | 1023 bytes | deviantintegral |
Comments
Comment #1
deviantintegral CreditAttribution: deviantintegral at Lullabot commentedComment #2
ufku CreditAttribution: ufku commentedI can commit this but i don't think a new hook will be added to d7.
Comment #3
deviantintegral CreditAttribution: deviantintegral at Lullabot commentedThere have been a few feature additions to D7 in terms of new config variables or debug tools like theme_debug. I agree it's not likely, but it's possible to be committed.
Comment #5
ufku CreditAttribution: ufku commentedCommitted a fix that calls
drupal_alter('file_stream_wrapper_uri_normalize', $uri, $scheme, $target);
directly.I guess this is better than waiting for the core commit.
Comment #7
deviantintegral CreditAttribution: deviantintegral at Lullabot commentedThanks! The commit is working well for me.