This was due to 'Bucket Policy Only' been turned on:
https://cloud.google.com/storage/docs/bucket-policy-only
On Wednesday, 27 March 2019 01:12:33 UTC, Noel McKeown wrote:
>
> Hi users,
>
> We are having some issue reading images stored on our bucket storage.
> Using a php55 agg engine to serve the web docs.
>
> Below is our environment and some sample code:
>
> *php.ini*
> extension = "fileinfo.so"
> extension = "intl.so"
> google_app_engine.allow_include_gs_buckets = "gs://
> safetyfreelancer-209721.appspot.com/"
>
> *app.yaml*
> service: phpmyadmin
> runtime: php55
> api_version: 1
>
> handlers:
>
> - url: /(.+\.(ico|jpg|png|gif))$
> static_files: \1
> upload: (.+\.(ico|jpg|png|gif))$
> application_readable: true
>
> - url: /(.+\.(htm|html|css|js))$
> static_files: \1
> upload: (.+\.(htm|html|css|js))$
> application_readable: true
>
> - url: /(.+\.php)$
> script: \1
> login: admin
>
> - url: /.*
> script: index.php
> login: admin
>
> *Test Code:*
>
> <?php
> use google\appengine\api\cloud_storage\CloudStorageTools;
> try {
>
> $photo =
> CloudStorageTools::getImageServingUrl('gs://safetyfreelancer-209721.appspot.com/uploads/profile_photos/4494316015c95582d11b344.51085825.jpg',
> ['size' => 100]);
>
> } catch (Exception $e) {
> print_r( $e->getMessage() );
> }
> ?>
>
> <?php if( !empty($photo) ): ?>
> <img src="<?php echo $photo ?>" alt="<?php echo $photo ?>" /
>
> <?php endif ?>
>
>
> *Test URL:*
>
> https://safetyfreelancer.com/test-permissions.php
>
>
> *Error on GCP Console:*
>
> PHP Fatal error: Uncaught exception
> 'google\appengine\api\cloud_storage\CloudStorageException' with message
> 'Unspecified error with image.' in
> /base/alloc/tmpfs/dynamic_runtimes/php55_dynamic/fc2f1b4915ea2bca/sdk/google/appengine/api/cloud_storage/CloudStorageTools.php:810
> Stack trace:
> #0
> /base/alloc/tmpfs/dynamic_runtimes/php55_dynamic/fc2f1b4915ea2bca/sdk/google/appengine/api/cloud_storage/CloudStorageTools.php(331):
>
> google\appengine\api\cloud_storage\CloudStorageTools::imagesApplicationErrorToException(Object(google\appengine\runtime\ApplicationError))
> #1
> /base/data/home/apps/g~safetyfreelancer-209721/20190326t123924.417045301748881360/src/SafetyFreel/Controllers/DefaultController.php(42):
>
> google\appengine\api\cloud_storage\CloudStorageTools::getImageServingUrl('gs://safetyfree...',
> Array)
> #2
> /base/data/home/apps/g~safetyfreelancer-209721/20190326t123924.417045301748881360/public/index.php(480):
> SafetyFreel\Controllers\DefaultController->serveFile('profile_photos/...')
> #3 [internal function]: {closure}('profile_photos/...' in
> /base/alloc/tmpfs/dynamic_runtimes/php55_dynamic/fc2f1b4915ea2bca/sdk/google/appengine/api/cloud_storage/CloudStorageTools.php
> on line 810
>
>
> The storage is public.
>
> Appreciate if someone can assist pinpoint the issue.
>
>
> Many Thanks,
>
> Noel
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/736773f7-e123-4770-97e7-631dd5331edb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.