Reputation: 4419
I need to get a video from a URL, for example:
https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20130722/5aacb76fc3fd47715c0329d1235dcccf/4fc612e92131e159abc761f7d54d86b5.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=AGgZb1eMr105RXcoQFp8yFFTfFg%3D&Expires=1374614893
and then use Google App Engine to save it to the blobstore (or possibly Google Cloud Storage if the blobstore can't download straight from a URL) is there a simple way to do this? I already have it set up so that I can get a user to upload a video but I am not sure about doing it this way. Is the URLFetch Library what I'm looking for?
Would it be something like:
class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
def post(self):
#I'm just not sure what to do here, how I can get that 'file' from a URL
upload_files = self.get_uploads('file')
blob_info = upload_files[0]
video = Video(
title = "some title",
video_ref = blob_info.key())
video.put()
Upvotes: 0
Views: 662
Reputation: 2276
Yeah you will need to use urlfetch then use the google cloud storage client library(https://developers.google.com/appengine/docs/python/googlecloudstorageclient/functions#open) to write the results. You need to consider that urlfetch response size is limited to 32mb so you need to split download into 32mb pieces and also there is a 60 seconds user request limit or 10 minute taskqueue limit or the use backends which doesn't have a timeout limit.
You could also directly upload to blobstore or cloudstorage (https://developers.google.com/appengine/docs/python/blobstore/#Uploading_a_Blob) which is handled by special instances that is designed to handle these uploads.
Upvotes: 1