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

vaibhavjain’s picture

Issue summary: View changes

Removing project specific names.

kirtivaland’s picture

Hello,

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.

amaisano’s picture

Also 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!

vaibhavjain’s picture

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

amaisano’s picture

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

vaibhavjain’s picture

Cool, Thanks for the info. I will try that with that version of the module.

deviantintegral’s picture

Status: Active » Needs review

I'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.

benhbell’s picture

This issue also affects me. On a clean drupal installation on Lamp stack

Ubuntu 14.04, Apache2, etc

Error
    Notice: Undefined offset: 0 in Drupal\amazons3\StreamWrapper->getExternalUrl() (line 221 of /var/www/vanilladrupal.com/html/sites/all/modules/amazons3/src/StreamWrapper.php).
    InvalidArgumentException: Was unable to parse malformed url: s3:/// in Drupal\amazons3\S3Url::factory() (line 129 of /var/www/vanilladrupal.com/html/sites/all/modules/amazons3/src/S3Url.php).

Installed drupal 7.32
Installed modules:

  • AmazonS3 7.x-2.0
  • Bulk Export 7.x-1.7
  • Chaos tools 7.x-1.7
  • Custom content panes 7.x-1.7
  • Custom rulesets 7.x-1.7
  • Page manager 7.x-1.7
  • Stylizer 7.x-1.7
  • Term Depth access 7.x-1.7
  • Views content panes 7.x-1.7
  • File Entity 7.x-2.0-beta2
  • IMCE 7.x-1.9
  • Media 7.x-2.0-beta1
  • Media Bulk Upload 7.x-2.0-beta1
  • Media Field 7.x-2.0-beta1
  • Media Internet Sources 7.x-2.0-beta1
  • Media WYSIWYG 7.x-2.0-beta1
  • Media WYSIWYG View Mode 7.x-2.0-beta1
  • Composer Manager 7.x-1.7
  • IMCE Wysiwyg API bridge 7.x-1.0
  • Wysiwyg 7.x-2.2
  • Views 7.x-3.11
  • Views UI 7.x-3.11

Ran and install composer install script (from /composer folder)

Any help on this would be appreciated.

mpiresolutions’s picture

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

  • deviantintegral committed c6ad1b5 on 7.x-2.x
    Issue #2502601: Fix notice on getExternalUri with no object key
    
deviantintegral’s picture

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

muhaha03’s picture

I 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).

deviantintegral’s picture

Let'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.

deviantintegral’s picture

I'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:

  • The latest dev release for both the AmazonS3 and IMCE modules
  • The patch to includes/file.inc as documented in the README for AmazonS3

deviantintegral’s picture

Status: Needs review » Postponed (maintainer needs more info)
pnetz’s picture

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

francois o’s picture

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

endless_wander’s picture

I'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

0 => filename.png

So, it seems like line 214 is not working because it expects to return a file?