Uploading file from external URL on Google App Engine with Python

kevin

Is it possible to upload an image from an external site (i.e. www.example.com/image.png) to the Google App Engine? This is not the same as uploading a file from a user submitted form. If it's possible, any solutions? I'm also using Google Cloud Storage, so if anybody has found a way to accomplish the same thing by uploading straight to Google Cloud Storage, please let me know.

-- UPDATE ---

I've followed the example from here - https://developers.google.com/appengine/docs/python/googlecloudstorageclient/getstarted and replaced the text write "abcd" with this:

url="example.com/image.jpeg"
opener1 = urllib2.build_opener()
page1 = opener1.open(url)

write_retry_params = gcs.RetryParams(backoff_factor=1.1)
gcs_file = gcs.open(filename,
                        'w',
                        content_type='image/jpeg',
                        options={'x-goog-meta-foo': 'foo',
                                 'x-goog-meta-bar': 'bar'},
                        retry_params=write_retry_params)
gcs_file.write(page1.read())
gcs_file.close()

The problem is - when I run this code, it tries to download the image to my computer (the client) instead of downloading to the gcs_file. I get the download file popup.... That's not what I'm trying to do. What am I doing wrong?

Faisal

Yes, you are looking at using the google cloud storage client library. Specifically this: https://developers.google.com/appengine/docs/python/googlecloudstorageclient/functions#open

Open it for writing then write the url fetched image.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

OAuth for Google App Engine Python

分類Dev

Uploading files to Google Cloud Storage from Localhost or external server

分類Dev

Python Change Directory Google App Engine

分類Dev

How can I make url rewrite on google cloud app engine?

分類Dev

Google app engine bulkloader opens empty file at upload

分類Dev

RSA in Google App Engine

分類Dev

google app engine and mongodb

分類Dev

Starting app engine modules in Google App Engine

分類Dev

Making a Google App Engine datastore key from a string

分類Dev

Getting Country / City data from google-app-engine

分類Dev

Google App Engine-JavaまたはPython?

分類Dev

How to force Google App Engine [python] to use SSL (https)?

分類Dev

How to sanitize html blob uploads in python in Google App Engine?

分類Dev

Cloud Tasks API for python2.7 google app engine

分類Dev

Google App Engine (Python SDK) - How to catch db exceptions

分類Dev

Upload media file from external URL to WordPress Media Library

分類Dev

Google Compute Engine for Web Server or App Engine

分類Dev

Unicode App Engine Python

分類Dev

Google App Engine Channel API

分類Dev

Google App EngineのOSGI?

分類Dev

Google App EngineとFirebase

分類Dev

Google App EngineとFirebase

分類Dev

Is Google App Engine memcache secure?

分類Dev

Google App Engine / _ah / health

分類Dev

Google App Engine Endpoints with Maven

分類Dev

Porting Application to Google App Engine

分類Dev

Google App Engine Java API

分類Dev

Google App Engine Java API

分類Dev

Create a search "engine" to get information from a Google DataStore in python