Forum

Thread tagged as: Problem, Error

Amazon S3 (Cloudfront) not uploading file

I currently have this in my bucket.php. But the image is not uploading. In runway.php, Access_key_id & secret_access_key is correct.

Perch Runway: 3.0.1
Production mode: Production (100)
Installed apps: content (3.0.1), assets (3.0.1), categories (3.0.1), perch_blog (5.5.1), perch_events (1.9.5), perch_gallery (2.8.9), perch_members (1.6.1), perch_backup (1.2)
DB driver: PDO
DB tables: perch2_backup_plans (0), perch2_backup_resources (0), perch2_backup_runs (3), perch2_blog_authors (1), perch2_blog_comments (0), perch2_blog_index (1930), perch2_blog_posts (10), perch2_blog_posts_to_tags (2), perch2_blog_sections (2), perch2_blog_tags (3), perch2_blogs (7), perch2_categories (11), perch2_category_counts (3), perch2_category_sets (4), perch2_collection_index (0), perch2_collection_items (1), perch2_collection_revisions (1), perch2_collections (0), perch2_content_index (9061), perch2_content_items (1534), perch2_content_locks (0), perch2_content_regions (104), perch2_events (2), perch2_events_categories (1), perch2_events_to_categories (2), perch2_gallery_albums (1), perch2_gallery_image_versions (6), perch2_gallery_images (1), perch2_members (12), perch2_members_forms (1), perch2_members_member_tags (37), perch2_members_sessions (2), perch2_members_tags (13), perch2_menu_items (13), perch2_navigation (13), perch2_navigation_pages (34), perch2_page_routes (14), perch2_page_templates (68), perch2_pages (62), perch2_resource_log (4344), perch2_resource_tags (0), perch2_resources (914), perch2_resources_to_tags (0), perch2_scheduled_tasks (1), perch2_settings (38), perch2_user_passwords (3), perch2_user_privileges (43), perch2_user_role_privileges (55), perch2_user_roles (8), perch2_users (12)
Users: 12
App runtimes:
<?php $apps_list = array( 'perch_members', 'perch_blog', 'perch_gallery', 'perch_events', 'perch_backup', );
Scheduled tasks for perch_blog: delete_spam_comments (1440 mins)
Editor plug-ins:
H1: 1faf3becf821a0912d27b8ef2383fb36
L1: 335813541ff8d23b27a57482926c5895
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
headerColour: #000000
content_singlePageEdit: 0
helpURL:
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
update_2.8.31: done
headerScheme: dark
update_runway_2.8.31: done
latest_version:
on_sale_version:
perch_members_update: 1.4
perch_members_login_page: /members/login.php?r={returnURL}
dashboard: 1
hide_pwd_reset: 0
content_hideNonEditableRegions: 1
content_frontend_edit: 0
perch_blog_update: 5.0.1
perch_blog_post_url: /news/{postSlug}
perch_blog_site_name:
perch_blog_slug_format: %Y-%m-%d-{postTitle}
perch_blog_akismet_key:
perch_blog_max_spam_days: 0
perch_blog_comment_notify: 0
update_runway_2.8.32: done
perch_gallery_update: 2.8.5
update_runway_2.8.34: done
perch_gallery_bucket_mode: single
perch_gallery_bucket: default
perch_gallery_basicUpload: 0
logoPath: /pwcms/resources/intranet-logo-1.png
perch_events_update: 1.8
update_runway_3.0: done
update_runway_3.0.1: done
perch_events_detail_url: /events/event.php?s={eventSlug}
perch_backup_mysqldump_path:
siteOffline: 0
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_SITEPATH: /var/www/vhosts/mysiteurl/httpdocs
PERCH_SCHEDULE_SECRET: WjrzUvLhTIZMWb3L
PERCH_DB_USERNAME: intranetbso
PERCH_DB_SERVER: localhost
PERCH_DB_DATABASE: intranetbso_
PERCH_DB_PREFIX: perch2_
PERCH_SSL: 1
PERCH_EMAIL_FROM: it@myemail.com
PERCH_EMAIL_FROM_NAME: Company name - Intranet
PERCH_LOGINPATH: /pwcms
PERCH_PATH: /var/www/vhosts/mysiteurl/httpdocs/pwcms
PERCH_CORE: /var/www/vhosts/mysiteurl/httpdocs/pwcms/core
PERCH_RESFILEPATH: /var/www/vhosts/mysiteurl/httpdocs/pwcms/resources
PERCH_RESPATH: /pwcms/resources
PERCH_HTML5: 1
PERCH_TZ: Europe/London
PERCH_MEMBERS_SESSION_TIME: 720 minutes
PERCH_PRODUCTION_MODE: 100
PERCH_FEATHERS: 1
PERCH_RUNWAY: 1
PERCH_ERROR_MODE: DIE
PERCH_DATE_LONG: %d %B %Y
PERCH_DATE_SHORT: %d %b %Y
PERCH_TIME_SHORT: %H:%M
PERCH_TIME_LONG: %H:%M:%S
PERCH_RUNWAY_ROUTED:
PERCH_STRONG_PASSWORDS:
PERCH_ASSET_VERSION: 7ca631ef9a54e99e413a
PERCH_DEBUG:
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: /var/www/vhosts/mysiteurl/httpdocs/pwcms/templates
PERCH_TEMPLATE_FILTERS:
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_XHTML_MARKUP:
PERCH_RWD: 1
PERCH_HTML_ENTITIES:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_PARANOID:
PERCH_FORCE_SECURE_COOKIES:
PERCH_DEFAULT_BUCKET: default
PERCH_TRANSLATION_ASSIST:
PERCH_PASSWORD_MIN_LENGTH: 6
PERCH_MAX_FAILED_LOGINS: 10
PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR
PERCH_VERIFY_UPLOADS:
PERCH_PRIV_ASSIST:
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
PERCH_APPS_EDITOR_PLUGIN: markitup
PERCH_APPS_EDITOR_MARKUP_LANGUAGE: markdown
Hosting settings

PHP: 7.1.4
Zend: 3.1.0
OS: Linux
SAPI: cgi-fcgi
Safe mode: not detected
MySQL client: mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $
MySQL server: 5.5.52-MariaDB
Free disk space: 36.78 GB
Extensions: Core, date, libxml, openssl, pcre, zlib, bz2, calendar, ctype, hash, filter, ftp, gettext, gmp, SPL, iconv, pcntl, readline, Reflection, session, standard, SimpleXML, sockets, mbstring, tokenizer, xml, cgi-fcgi, mysqlnd, bcmath, curl, dba, dom, enchant, fileinfo, gd, imagick, imap, intl, json, ldap, exif, mcrypt, mysqli, odbc, PDO, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, pspell, redis, soap, sqlite3, sysvmsg, sysvsem, sysvshm, tidy, xmlreader, xmlrpc, xmlwriter, xsl, zip, Zend OPcache
GD: Yes
ImageMagick: Yes
PHP max upload size: 128M
PHP max form post size: 8M
PHP memory limit: 128M
Total max uploadable file size: 8M
Resource folder writeable: Yes
Session timeout: 24 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: Yes
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
PP_CUSTOM_PHP_INI: /var/www/vhosts/system/mysiteurl/etc/php.ini
PP_CUSTOM_PHP_CGI_INDEX: plesk-php71-fastcgi
SCRIPT_NAME: /pwcms/core/settings/diagnostics/index.php
REQUEST_URI: /pwcms/core/settings/diagnostics/?extended
QUERY_STRING: extended
REQUEST_METHOD: GET
SERVER_PROTOCOL: HTTP/1.0
GATEWAY_INTERFACE: CGI/1.1
REMOTE_PORT: 34670
SCRIPT_FILENAME: /var/www/vhosts/mysiteurl/httpdocs/pwcms/core/settings/diagnostics/index.php
SERVER_ADMIN: it@myemail.com
CONTEXT_DOCUMENT_ROOT: /var/www/vhosts/mysiteurl/httpdocs
REQUEST_SCHEME: https
DOCUMENT_ROOT: /var/www/vhosts/mysiteurl/httpdocs
REMOTE_ADDR: 10.0.0.21
SERVER_PORT: 443
SERVER_ADDR: 10.0.0.120
SERVER_NAME: mysiteurl
SERVER_SOFTWARE: Apache
HTTP_COOKIE: PHPSESSID=0d47g6g9js0q0vn812s9dd7v2h; cmsa=1
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8
HTTP_ACCEPT_ENCODING: gzip, deflate, sdch, br
HTTP_REFERER: https://mysiteurl/pwcms/core/settings/diagnostics/
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_CONNECTION: close
HTTP_X_ACCEL_INTERNAL: /internal-nginx-static-location
HTTP_X_REAL_IP: 10.0.0.21
HTTP_HOST: mysiteurl
HTTPS: on
SCRIPT_URI: https://mysiteurl/pwcms/core/settings/diagnostics/
SCRIPT_URL: /pwcms/core/settings/diagnostics/
UNIQUE_ID: WPd3EukLkmlKGRAetzThiAAAAM4
FCGI_ROLE: RESPONDER
PHP_SELF: /pwcms/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1492612882.2397
REQUEST_TIME: 1492612882
Edward Johansen

Edward Johansen 0 points

  • 4 years ago

bucket.php

<?php
    return [
        'Aws_System' => [
                 'type'      => 'amazon_s3',
                 'region'    => 'eu-central-1',
                 'web_path'  => 'https://cdn.mydomain.com/assets/images/system',
                 'file_path' => 'bucketname/assets/images/system',
         ],
    ]
    ?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

It looks like you have your bucket configuration in runway.php instead of buckets.php

Sorry, I wrote the wrong file name. That is in bucket.php

I have a custom domain name using CNAME for the cloudfront if it helps.

Should i use:

'images' => [
      'type'      => 'amazon_s3',
      'region'    => 'eu-central-1',
      'web_path'  => 'https://abcdefghijk.cloudfront.net',  (shall I include the image folder location)
      'file_path' => 'myproject.images', (should this be the bucket name mybucket/images? - The documentation is not clear)
],
Drew McLellan

Drew McLellan 2638 points
Perch Support

The file_path needs to be the name of the S3 bucket you're uploading to.

Still not working

Looking at the server log, A few errors there. The website is SSL enabled & S3

Warning 1
mod_fcgid: stderr: PHP Warning: The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256. in /var/www/vhosts/mydomain.com/httpdocs/pwcms/addons/apps/perch_s3/lib/aws/aws-sdk-php/src/Aws/S3/StreamWrapper.php on line 758, referer: https://mydomain.com/pwcms/core/apps/content/edit/?id=303&itm=646

Warning 2
mod_fcgid: stderr: PHP Warning: finfo_file(): Failed identify data 0:(null) in /var/www/vhosts/mydomain.com/httpdocs/pwcms/core/lib/PerchImage.class.php on line 402, referer: https://mydomain.com/pwcms/core/apps/content/edit/?id=303&itm=646    

Warning 3
mod_fcgid: stderr: PHP Fatal error: Uncaught Error: Call to a member function id() on boolean in /var/www/vhosts/mydomain.com/httpdocs/pwcms/core/apps/assets/modes/upload.pre.php:37, referer: https://mydomain.com/pwcms/core/apps/content/edit/?id=303&itm=646

Warning 4
mod_fcgid: stderr: Stack trace:, referer: https://mydomain.com/pwcms/core/apps/content/edit/?id=303&itm=646

Warning 5
mod_fcgid: stderr: #0 /var/www/vhosts/mydomain.com/httpdocs/pwcms/core/apps/assets/upload/index.php(22): include(), referer: https://mydomain.com/pwcms/core/apps/content/edit/?id=303&itm=646
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok. It's working fine with Frankfurt here, so I'll need to look into it. I don't (and won't) have an immediate answer for you as to the cause.

Our bucket is using London region. So London region will be eu-central-2, Right?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You have your region set as eu-central-1