Forum

Thread tagged as: Runway, Gallery

S3 Uploads silently failing

I've migrated assets from perch/resources to S3 and wired up the buckets.php config file to reference each bucket used. Perch is correctly using these S3 assets, but uploading new assets silently fails. Perch thinks the upload completes successfully and includes what should be the correct asset URL, but the image tags are broken and the asset does not exist on S3.

Additionally, when selecting a broken image in gallery app and attempting to re-upload the image file, Perch outputs the following errors above the navbar:

I've verified the keys I'm using are valid by connecting via Transmit and adding/removing files to/from S3. I've tried with and without the bucket policy and CORS config detailed in this post, without any change.

Any ideas? Are you able to share the bucket policy and CORS settings you tested with?

Thanks in advance.

Diagnostic:

Perch Runway: 2.8.13, PHP: 5.6.10-1+deb.sury.org~trusty+1, MySQL: 5.5.43, with PDO
Server OS: Linux, apache2handler
Installed apps: content (2.8.13), assets (2.8.13), categories (2.8.13), perch_blog (4.6), perch_forms (1.8.3), perch_gallery (2.8.6)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_forms', 'perch_gallery' );
PERCH_LOGINPATH: /admin
PERCH_PATH: /var/www/admin
PERCH_CORE: /var/www/admin/core
PERCH_RESFILEPATH: /var/www/admin/resources
Image manipulation: GD Imagick
PHP limits: Max upload 32M, Max POST 32M, Memory: 512M, Total max file upload: 32M
Resource folder writeable: Yes
HTTP_HOST: 192.168.33.10
DOCUMENT_ROOT: /var/www/
REQUEST_URI: /admin/core/settings/diagnostics/
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
Brad Cerasani

Brad Cerasani 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Could be a buckets.php issue - what does your entry look like?

Reduced test buckets.php examples:

This fails (attempting to write to bucket root):

<?php
  return [
    'my-style' => [
      'type'      => 'amazon_s3',
      'web_path'  => 'https://s3.amazonaws.com/bucketname',
      'file_path' => 'bucketname',
    ],
  ];

As does this (attempting to write to directory within bucket):

<?php
  return [
    'my-style' => [
      'type'      => 'amazon_s3',
      'web_path'  => 'https://bucketname.s3.amazonaws.com',
      'file_path' => 'bucketname/my-style',
    ],
  ];

As does this:

<?php
  return [
    'my-style' => [
      'type'      => 'amazon_s3',
      'web_path'  => 'https://d4an6a1kfx6yk.cloudfront.net',
      'file_path' => 'my-style',
    ],
  ];

As does this:

<?php
  return [
    'my-style' => [
      'type'      => 'amazon_s3',
      'web_path'  => 'https://d4an6a1kfx6yk.cloudfront.net',
      'file_path' => 'bucketname/my-style',
    ],
  ];

The following bucket config does work with some image fields inside page regions, but does not work with buckets defined by Gallery app:

<?php
  return [
    'my-style' => [
      'type'      => 'amazon_s3',
      'web_path'  => 'https://bucketname.s3.amazonaws.com/directoryname',
      'file_path' => 'bucketname/directoryname',
    ],
  ];

Instead of Gallery app uploading a new image to the bucket directory manually defined in buckets.php, Perch creates bucketname/directoryname inside perch/addons/apps/perch_gallery, but still thinks the image is located on S3.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Dynamic buckets from the Gallery app will not work - I believe they're created under the default bucket.

I was operating under the assumption that existing buckets created by Gallery app could use S3 if the bucket names were manually defined in buckets.php (This does work for displaying assets, FWIW). New albums created by Gallery app would then only exist on the server with the Perch install, and could later be moved to S3 once support improves. Is this not the case?

Drew McLellan

Drew McLellan 2638 points
Perch Support

That's right - if the items are in the bucket list then there should be no issue. The only issue might arise in dynamically creating new buckets on S3.

So in theory this should work. Any idea why images are uploading to perch/addons/apps/perch_gallery instead of S3, or additional steps I can take to troubleshoot?

Drew McLellan

Drew McLellan 2638 points
Perch Support

That sounds like the path is missing so it's going into the local directory to me.

I'll have to dig into the Gallery app and take a look. It predates Runway.