blobstore

Open a file from urlfetch in GAE

与世无争的帅哥 提交于 2019-12-08 03:09:46
问题 I'm trying to open a file in GAE that was retrieved using urlfetch() . Here's what I have so far: from google.appengine.api import urlfetch result = urlfetch.fetch('http://example.com/test.txt') data = result.content ## f = open(...) <- what goes in here? This might seem strange but there's a very similar function in the BlobStore that can write data to a blobfile: f = files.blobstore.create(mime_type='txt', _blobinfo_uploaded_filename='test') with files.open(f, 'a') as data: data.write

How to upload image from url to Blobstore?

不羁岁月 提交于 2019-12-07 13:29:06
问题 The Google App Engine Files API now supports programmatic creation if blobstore blobs. I'm trying this out by attempting to fetch an image over http and store it to the blobstore: file_name = files.blobstore.create(mime_type='image/jpeg') image = urllib2.urlopen(url) with files.open(file_name, 'a') as f: f.write(image) # LINE 142 files.finalize(file_name) blob_key = files.blobstore.get_blob_key(file_name) This code is throwing the error: File "/Users/willmerydith/repos/spam/admin.py", line

Saving blobs with Google Endpoint

三世轮回 提交于 2019-12-07 11:13:06
问题 I have an app that allows users to save blobs in the blobstore. I have a schema that does so presently, but I am interested in something simpler and less twisted. For context, imagine my app allows users to upload the picture of an animal with a paragraph describing what the animal is doing. Present schema User calls my endpoint api to save the paragraph and name of the animal in entity Animal . Note: The Animal entity actually has 4 fields ( name , paragraph , BlobKey , and blobServingUrl as

Retrieving .txt file contents in Google AppEngine

故事扮演 提交于 2019-12-07 09:41:20
问题 I'm trying to Upload a text file using : <input type="file" name="file"> and this file is retrieved using: class UploadHandler(webapp2.RequestHandler): def post(self): file=self.request.POST['file'] self.response.headers['Content-Type'] = "text/plain" self.response.write(file.value) my output is: Content-Type: text/plain MIME-Version: 1.0 Content-Length: 312 Content-MD5: MDIzYzM5YmNmOWRmMzY5Zjk2MTYzZTUzNjYwMTg5YjM= content-type: text/plain content-disposition: form-data; name="file"; filename

Best way to link datastore entity to its blobstore image?

Deadly 提交于 2019-12-07 08:23:28
Let's say I have a model for my email address book: class contact(db.Model): email = db.EmailProperty() image = #Hmm. My contacts' images will be stored in the Blobstore, and served at various sizes. So, should I use a db.ReferenceProperty(BlobInfo) such that I can serve it by doing: get_serving_url(alice.image.key, size=x) Or should I use a db.StringProperty so that I don't have to make the second read in order to get the key: get_serving_url(alice.image, size=x) Or should I use a db.LinkProperty for the base URL, post-fixing the size needed: alice.image+'=sx' I don't foresee needing anything

Moving Blobstore to GCS: Google App Engine Python

本小妞迷上赌 提交于 2019-12-07 06:47:28
问题 Here is my existing py code for data uploading to blobstore . from google.appengine.api import files def save_data_to_blob_store(data): # Create the file file_name = files.blobstore.create(mime_type='application/octet-stream') # Open the file and write to it with files.open(file_name, 'a') as f: f.write(data) # Finalize the file. Do this before attempting to read it. files.finalize(file_name) # Get the file's blob key blob_key = files.blobstore.get_blob_key(file_name) return str(blob_key) Now

How long to blob urls served by the app engine remain valid?

蹲街弑〆低调 提交于 2019-12-07 06:36:36
问题 I was wondering if anyone knew how long image urls served back from the google app engine blob store remain valid for? I have been tracking on url that i served an image from the blob store on 1/3/13 and its still there. I am ask specifically so i can cache the image url instead of attempting to serve it repeatedly. If i did this i would still check if the image is there, but how often would i need to check that thanks! 回答1: They remain valid until either you a. call delete_serving_url, or b.

How long does URL from ImagesService.getServingUrl last

天大地大妈咪最大 提交于 2019-12-07 06:27:04
问题 I'm working with the blobstore and imagesService in App Engine. I'm wondering how long a URL I get from imagesService.getServingUrl(blobKey) will last. If I'm using this to store a users profile picture, can I store this URL in the user or should I store the BlobKey and get the servingUrl each time i need the picture? 回答1: The URL will last indefinitely. You should definitely still store the blobkey anyway, though, or you will have no way to delete blobs once you no longer need them, or to

Video files conversion/transcoding Google App Engine

本小妞迷上赌 提交于 2019-12-06 19:27:19
问题 I want to start a cloud computing project with the simple task to: Receive uploaded video files Do some transcoding / converting to them Allow user to download / stream the generated file I was thinking ffmpeg as an external command line tool integrated in a Java/Google App engine Application . Since it was fairly hard to be assured about the limitations of the framework, can someone tell me if this is feasible? Thank you in advance! 回答1: You have to offload ffmpeg to an external server, like

how to simulate image upload to google app engine blobstore

[亡魂溺海] 提交于 2019-12-06 09:17:23
问题 I'm uploading images to the GAE blobstore using create_upload_url uploadURL = blobstore.create_upload_url('/upload') For the purpose of unit testing the gae code, can you simulate the image upload? OR should I insert the image data in my test bed and assume the upload is successful? If so, how do you upload an image to the test bed? 回答1: Agree with @fredrik on what exactly you're testing there. Anyway, if you're doing some functional/blackbox/similar testing, you could simply use Webtest