0
votes

I'm trying to upload an image to a bucket on Google App Engine. The php code sample here works:

https://cloud.google.com/storage/docs/uploading-objects

I use the below code to get $source for the above:

https://cloud.google.com/appengine/docs/standard/php/googlestorage/user_upload

However, it says this solution (createUploadUrl) is not recommended, and it only works on my development server, not my production server. What is the proper way to get a file path using Google App Engine?

2

2 Answers

1
votes

The method “createUploadUrl” is not recommended is because the API is deprecated. As the second link that you shared indicates, your apps will need to upgrade to the recommended APIs, which are the Google Cloud Client Libraries. And it is exactly the same API that the sample code uses in the first link you shared.

For the proper API method to invoke to get a URL for uploaded files, please refer to https://googleapis.github.io/google-cloud-php/#/docs/cloud-storage/v1.14.0/storage/storageobject?method=signedUploadUrl.

0
votes

Based on the sample code files, a typical process should be as such:

  1. Qualified GET requests are received by the application and trigger a function to process the requests. In the function, the createUploadUrl method is invoked to generate an upload URL (file link: https://github.com/GoogleCloudPlatform/php-docs-samples/blob/6d6757ee1df71e22ded52c2c78edf58786a99961/appengine/php55/storage/app.php#L43 ).
  2. Then in the HTML file, the created upload URL will be used as the action parameter for the form to accept uploads.(file link: https://github.com/GoogleCloudPlatform/php-docs-samples/blob/6d6757ee1df71e22ded52c2c78edf58786a99961/appengine/php55/storage/storage.html.twig#L159 ).