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.

CommentFileSizeAuthor
#1 2530388.1-normalize-uri.patch1023 bytesdeviantintegral
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

deviantintegral’s picture

FileSize
1023 bytes
ufku’s picture

I can commit this but i don't think a new hook will be added to d7.

deviantintegral’s picture

There 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.

  • ufku committed 52dfd14 on 7.x-1.x
    Added 'file_stream_wrapper_uri_normalize' altering to imce_dir_uri() as...
ufku’s picture

Status: Needs review » Fixed

Committed 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

deviantintegral’s picture

Thanks! The commit is working well for me.