Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload files in Google App Engine

I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through db.TextProperty and db.BlobProperty.

I'll be glad anyone can provide code sample (both the client and the server side) on how this can be done.

like image 433
Graviton Avatar asked Sep 17 '08 09:09

Graviton


People also ask

How do I upload files to Google Shell?

Upload and downloading files and folders Files and folders can only be uploaded to and downloaded from your home directory. In your Cloud Shell Editor Explorer, right-click a directory or file and then click Copy Download Link, Download, or Upload Files. Alternatively, you can navigate to File > Download/Upload Files.

How do I upload files to GCP?

In the Google Cloud console, go to the Cloud Storage Buckets page. In the list of buckets, click on the name of the bucket that you want to upload an object to. In the Objects tab for the bucket, either: Drag and drop the desired files from your desktop or file manager to the main pane in the console.


1 Answers

In fact, this question is answered in the App Egnine documentation. See an example on Uploading User Images.

HTML code, inside <form></form>:

<input type="file" name="img"/>

Python code:

class Guestbook(webapp.RequestHandler):   def post(self):     greeting = Greeting()     if users.get_current_user():       greeting.author = users.get_current_user()     greeting.content = self.request.get("content")     avatar = self.request.get("img")     greeting.avatar = db.Blob(avatar)     greeting.put()     self.redirect('/')
like image 73
sastanin Avatar answered Oct 13 '22 11:10

sastanin