Superbalist / flysystem-google-cloud-storage

Flysystem Adapter for Google Cloud Storage
MIT License
265 stars 105 forks source link

proposed signedUrl method #43

Open beesperester opened 7 years ago

beesperester commented 7 years ago

I think it would be great to add a public signedUrl method which you can use to present an expiring link to a 3rd party. To implement this feature GoogleStorageAdapter needs to have access to the service-account .json-file to retrieve needed information about client_email and private_key to sign the request. I therefor added a new __construct parameter $key_file_path and a new protected var $auth in which the json decoded data will be stored.

matthewgoslett commented 7 years ago

Thanks for your contribution.

My only concern with this is that it only works for auth via a key file, where as there are many ways for auth to be configured and auto-discovered in the Google Client.

 * 1. The client will first look at the GOOGLE_APPLICATION_CREDENTIALS env var.
 *    You can use ```putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json');``` to set the location of your credentials file.
 *
 * 2. The client will look for the credentials file at the following paths:
 * - windows: %APPDATA%/gcloud/application_default_credentials.json
 * - others: $HOME/.config/gcloud/application_default_credentials.json
 *
 * If running in Google App Engine, the built-in service account associated with the application will be used.
 * If running in Google Compute Engine, the built-in service account associated with the virtual machine instance will be used.
artworkad commented 7 years ago

🌮

Rkallenkoot commented 7 years ago

Google has implemented the signedURL functionality in their google/cloud repository for PHP. The only thing that's necessary is to allow ^0.33.0 of google/cloud to be used with this package.

I've opened a PR for this already #62

chrisgillis commented 6 years ago

+1 for signed url