I have managed to create a file in GCS in the post method of a webapp2 handler of a Google App Engine application. I can't see how to copy the content of a posted file in the file created in GCS. Here is my code
inFile = self.request.POST.multi['file'].file
gcs_file = gcs.open(filename,
'w',
content_type='text/plain',
options={'x-goog-meta-foo': 'foo',
'x-goog-meta-bar': 'bar'},
retry_params=write_retry_params)
while 1:
line = inFile.readline()
if not line: break
gcs_file.write(line)
gcs_file.close()
At the end of the process the file in GCS is 0 byte
UPDATE There is a reason why I am not using the blobstore. When using the Blobstore you have to create an url and sand it back to the client. it is the client that performs the actual upload. INSTEAD I need to encrypt the file on the server before to put it in the GCS. Thus I need to receive the file from the client, encrypt it on the server and store it in the GCS.
logging, that you've properly received the file with the content length you expect from the POST? - Zach Young