Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When you use IMCE to browse files in CKEditor, you see an error in the popup. Error below
Notice: Undefined offset: 0 in Drupal\amazons3\StreamWrapper->getExternalUrl() (line 221 of ----/sites/all/modules/amazons3/src/StreamWrapper.php).
LogicException: A URI must be set before calling getOptions(). in Drupal\amazons3\StreamWrapper->getOptions() (line 358 of ----/sites/all/modules/amazons3/src/StreamWrapper.php).
This is with the latest version of all 3 modules.
By looking at the issue queue, I believe, this is working with the 7.x-1.x version on amazons3 module, as there are some issues related to it.a
Comments
Comment #1
vaibhavjainRemoving project specific names.
Comment #2
kirtivaland CreditAttribution: kirtivaland commentedHello,
I am facing the similar issue after integrating Amazons3 module. I have integrated "amazons3-7.x-2.0" module. I wanted to know how you had solve this issue.
I will appreciate if you can help me in this matter.
Thanks in advance.
Comment #3
amaisano CreditAttribution: amaisano commentedAlso getting a similar, perhaps related error
User warning: A URI must be set before calling getOptions(). in Aws\S3\StreamWrapper->triggerError() (line 785 of /Users/Adamo/GIT/nexamp/public_html/sites/all/libraries/composer/aws/aws-sdk-php/src/Aws/S3/StreamWrapper.php).
It only occurs when I try to delete an s3:// file - it won't let me. There's no way to delete it!
Comment #4
vaibhavjainHello amaisano,
You mention that it occurs when you try to delete an s3 file. Just wanted to confirm, are you able to open the Amazon S3 bucket inside IMCE ?
I am not able to open that as well, hence cant add any images to the CKEditor and body.
Comment #5
amaisano CreditAttribution: amaisano commented@vaibhavjain I don't use the media browser or allow inserts of S3 content, so unfortunately I wouldn't be able to tell you. However I did find that using the 7.x-1.1 version of Amazon S3 cleared up this error.
Comment #6
vaibhavjainCool, Thanks for the info. I will try that with that version of the module.
Comment #7
deviantintegral CreditAttribution: deviantintegral at Lullabot commentedI've filed a patch to IMCE to support S3 over at #2530388: Pass generated URIs through file_stream_wrapper_uri_normalize() for S3 support.
I haven't used the media browser at all - however, we do support the media module itself, so I think it's likely to work.
The notice being thrown here is an actual bug, and unrelated to IMCE itself. Since it's in the StreamWrapper, I've filed a PR over at https://github.com/justafish/drupal_amazons3/pull/36 to kick off tests. You should be able to apply https://patch-diff.githubusercontent.com/raw/justafish/drupal_amazons3/p... to see if it resolves the notice for you.
Comment #8
benhbell CreditAttribution: benhbell commentedThis issue also affects me. On a clean drupal installation on Lamp stack
Ubuntu 14.04, Apache2, etc
Installed drupal 7.32
Installed modules:
Ran and install composer install script (from /composer folder)
Any help on this would be appreciated.
Comment #9
mpiresolutions CreditAttribution: mpiresolutions commentedI am having the same issue as BenBell. Any help on this would be great - Have spent so much time on this and I am at a roadblock.
Comment #11
deviantintegral CreditAttribution: deviantintegral at Lullabot commentedDid you also apply the patch I submitted to IMCE over at #2530388: Pass generated URIs through file_stream_wrapper_uri_normalize() for S3 support?
I just committed the patch to fix the notice.
Comment #12
muhaha03 CreditAttribution: muhaha03 commentedI got all most the same problem like #8.
30449322 12/Aug 18:54 error php InvalidArgumentException: Was unable to parse malformed url: s3:///.htaccess in Drupal\amazons3\S3Url::factory() (line 129 of /ebs/*****/sites/all/modules/amazons3/src/S3Url.php).
Comment #13
deviantintegral CreditAttribution: deviantintegral at Lullabot commentedLet's start with basic IMCE without media module or WYSIWYG integration. If you set your default file system to S3, can you use the IMCE browser at /imce to view and upload files? I just tested with the latest IMCE dev release and it worked for me.
This obviously needs better docs so I'm going to start on that.
Comment #14
deviantintegral CreditAttribution: deviantintegral at Lullabot commentedI've opened a PR for a small update to the README: https://github.com/justafish/drupal_amazons3/pull/40
Could someone try out the basic IMCE functionality? For that, all you need is:
Comment #16
deviantintegral CreditAttribution: deviantintegral at Lullabot commentedComment #17
pnetz CreditAttribution: pnetz commentedI ran into the same problem after vanilla installation with all patches applied - both raw image field and with media widget produced the StreamWrapper.php error on delete and the stale files were left in the bucket.
Updating amazons3 to the current unstable release (7.x-2.1-beta1+0-dev) fixed the problem - files now get properly removed from the on delete without error messages.
Comment #18
francois o CreditAttribution: francois o commentedI ran into this issue to (but unrelated to IMCE). Same error message on node delete.
I'm running a simple amazons3 - file_entity package configured to work with a cloudfront distribution and presigned urls. Everything is patched as per module's page.
I have created a single node type with a file field and amzons3 storage. Everything works like a charm, creating new node, uploading media, viewing node via cloudfront url with presigned url. The only thing that fails is the node delete or even file_delete that triggers the error: A URI must be set before calling getOptions() and does not delete the file on S3.
As #17 using latest 2.x dev fixed the issue (beta4).
It would be great to have a patch for the stable version.
Comment #19
endless_wander CreditAttribution: endless_wander as a volunteer commentedI'm having the same problem when using IMCE from CKEditor.
The problem appears to occur at line 214 of StreamWrapper.php where the path segments are not built:
$path_segments = $this->uri->getPathSegments();
$path_segments is returning as an empty array and causing the problems later on.
$this->getUri() returns the correct s3 uri for my site.
getPathSegments() comes from Guzzle:
return array_slice(explode('/', $this->getPath()), 1);
in my case, my $this->getPath() returns just "/folder_name" so with that array_slice, there would be nothing returned.
on my regular file upload fields that are working, $this->uri->getPathSegments() returns an array of
So, it seems like line 214 is not working because it expects to return a file?