0

I am trying to upload a file to POST API request. I am able to give the file as input to the request if it is my local system path, but when I productionize this, the file should be taken from GCS bucket. Any inputs on this? Below is the code used for my local system file upload:


import requests
url = "API host url"

payload = {'type': 'application/x-zip-compressed'}
files=[
  ('config-file',('MoveData.zip',open('/C:/Users/xyz/Downloads/MoveData.zip,'rb'),'application/zip'))
]
headers = {
  'accept': 'application/json',
  'accessKey': 'accessKeyxxxxxxxx',
  'secretKey': 'secretkeyxxxxxxxx',
  'Content-Type': 'multipart/form-data'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)

This works if it is local file but looking for input on how to give GCS file

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Sri Bharath
  • 115
  • 1
  • 2
  • 10

0 Answers0