Home > Software design >  upload GCS file to specific service via Curl
upload GCS file to specific service via Curl

Time:01-07

I have file in cloud storage bucket gs://myfile/test.xlsx

I would like to create a curl command which post this file into a service like the following

curl -F "file=@gs://myfile/test.xlsx" https://myservice/Service/extraction

This command works fine with a local file but it doesn't work when I use a file located in GCS

CodePudding user response:

Update:

Try to create a signed url for the object, for you to be able access it in curl without using authentication. To create a signed URL that can get an object from a bucket, you need a service account and run the command gsutil signurl, for example:

gsutil signurl -d 10m key.json gs://myfile/test.xlsx
  • 10m is the duration of generated signed URL of object
  • key.json is name of private key of existing service account

Use the produced signed URL from the command where the string beginning is : https://storage.googleapis.com then try it with curl command:

curl -F "[signedurl]" https://myservice/Service/extraction
  •  Tags:  
  • Related