Forum
Moving existing resources to an Amazon S3 bucket
I'm having trouble trying to serve all images from an Amazon S3 bucket ('assets-cdn') in Runway 3; I've copied all images from my local resources folder to an Amazon S3 bucket and set this as the default bucket in config.php - these were initially uploaded to the default bucket prior to setting up the S3 bucket. I've also set the PERCH_RESPATH to the S3 cloudfront web path, i.e.
define('PERCH_RESPATH', 'https://cdn.hiddenireland.com');
define('PERCH_DEFAULT_BUCKET','assets-cdn');
All appears fine until I want to edit an existing image: when I edit a blog post in Runway, the existing image loads up fine and is being served from the Cloudfront CDN web path as expected. However, when I select and save a new image (from the default bucket because nothing appears under the new 'assets-cdn' bucket), the image is missing from the post as all the versions of the image are uploading to the local resources folder as opposed to the 'assets-cdn' S3 bucket.
Only if I choose an image that was uploaded to the 'assets-cdn' bucket, do versions of the image get saved to the correct location, i.e. to the S3 bucket. So to make all images in the assets panel to appear under the 'assets-cdn' bucket so that they are saved in the right location, can I just update resourceBucket column in the perch2_resources? i.e. run the following query on the db:
UPDATE perch2_resources SET resourceBucket='assets-cdn' WHERE resourceBucket='default'
Does this look safe enough? Also, do I need to add the buckets="assets-cdn" attribute to all the image tags in my templates or does setting the default bucket to 'assets-cdn' in config.php cover this?
Big thanks! A
Summary information
Perch Runway: 3.0.10, PHP: 5.6.31, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (3.0.10), assets (3.0.10), categories (3.0.10), perch_blog (5.6.1), perch_forms (1.9)
App runtimes: <?php $apps_list = [ 'perch_blog', 'perch_forms', ];
PERCH_LOGINPATH: /perch
PERCH_PATH: /Users/adam/Sites/hiddenireland.com/site/perch
PERCH_CORE: /Users/adam/Sites/hiddenireland.com/site/perch/core
PERCH_RESFILEPATH: /Users/adam/Sites/hiddenireland.com/site/perch/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
HTTP_HOST: hiddenireland.dev
DOCUMENT_ROOT: /Users/adam/Sites/hiddenireland.com/site
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Just a quick follow up - I ran the above mysql update on my local MAMP (php 5.6) and all appeared to work ok, so I tried the staging server (php 5.4) and assets won't display. Is there a minimum php version for amazon S3 resource buckets to work?
Thanks again!
There's currently no support for moving assets between buckets.
Does adding a new asset work?
Adding / uploading new assets works fine on local Mamp (php5.6).
On php5.4 no assets are displayed in assets panel when an amazon_s3 bucket type is declared in buckets.php. Switching to php5.6 fixes the problem but upgrading php version on the live (shared hosting) server is another story!
Hi Drew, can you confirm whether S3 buckets should work with Runway 3 on php 5.4? Or should I push to get hosting upgraded? Thanks again.
This is very interesting lets us know how you went. Php 5.6 is cutoff/.
If you have the option to upgrade you really should. PHP 5.4 is very old.