I have a (ndb.model) 'table' in app engine to which I need to add 'attachments' such as .jpg, .doc, xls and so on. I cannot pre-determine what these files will be, it's up to the user. This was reasonably easy using blobkey / blobstore but I am having trouble with Google Cloud Storage for this purpose.
my html is simple:
<label for="form_attach">Please select Attachment</label>
<input type="file" name="form_attach" id="form_attach" />
My Python code is also simple:
tempblob = self.request.get('form_attach')
logging.error(repr(tempblob)) -- shows the contents of tempblob
So... How do I know the content-type (mime type) of the incoming blob so that I can save it in Google Cloud Storage correctly? I need to set the content-type when the blob is stored so that it will serve / display correctly.
gcs.stat(...).content_type looks like it's what I need but it requires a valid, stored, GCS file from which to retrieve the information. Similarly Python's mimetypes needs a file name but I seem to retrieve the contents of the file.
Any pointers will be appreciated.
Thanks David