Classic Google App Engine - storing an uploaded image to Cloud Storage - how to, on local dev environment?

107 views
Skip to first unread message

david...@gmail.com

unread,
Aug 11, 2016, 2:58:50 AM8/11/16
to google-appengine-go
Hi, I really need some help here - I've spent ages experimenting and trying to find a good example on how to upload an image from browser to Cloud Storage that doesn't involve user ownership with oAuth, but now I've read this comment in a sample:


// NOTE: the cloud.google.com/go/storage package is not compatible with
// dev_appserver.py, so this example will not work in a local development
// environment.

I'm wondering, is it even possible? How do I write my app if I can't run on my local machine?


Dave Day

unread,
Aug 11, 2016, 9:21:38 PM8/11/16
to david...@gmail.com, google-appengine-go
Can you explain a little about what you mean by "user ownership with OAuth"? What use case are you aiming at?

The easiest way to get uploads from users in app engine is with blobstore.UploadURL and its partner blobstore.ParseUpload (https://godoc.org/google.golang.org/appengine/blobstore#UploadURL). Both of these URLs work perfectly well with the dev environment.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine-go+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

david...@gmail.com

unread,
Aug 11, 2016, 10:43:01 PM8/11/16
to google-appengine-go, david...@gmail.com
I'm wanting the user to fil out a form in the browser, most of the fields will end up in the datastore but the user can also upload an image from a file field within the multipart form. That image will be public, i.e. not owned by them. This image will then be used by the site on various pages.

As to the blobstore, the docs recommend using Cloud Storage instead; I have not found any statements that say Cloud Storage does not work with classic app engine.

Thanks, for helping out here.

Dave Day

unread,
Aug 11, 2016, 11:03:21 PM8/11/16
to david...@gmail.com, google-appengine-go
It sounds like that will suit your needs then. Note that you can specify a bucket name in the upload options which make sure the upload ends up in cloud storage:

To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine-go+unsubscribe...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

david...@gmail.com

unread,
Aug 12, 2016, 1:33:12 AM8/12/16
to google-appengine-go, david...@gmail.com
Thanks Dave, I have your suggest approach working. (Who would have known to use the blobstore library to upload to cloud storage?)

I specified my default cloud storage bucket in the options to blobstore.UploadURL.

However, in the cloud storage console, it looks like my image has been uploaded to the blobstore until I click an icon and then I get this popup:

"This blob is stored in Google Cloud Storage. However, you should not manage it there. If you move, copy, or rename your blob in Google Cloud Storage, you will no longer be able to access it in Blobstore."

So now I'm a bit worried that this method is going to come back and bite me. Should I be concerned?








On Friday, August 12, 2016 at 1:03:21 PM UTC+10, Dave Day wrote:
It sounds like that will suit your needs then. Note that you can specify a bucket name in the upload options which make sure the upload ends up in cloud storage:
On 12 August 2016 at 12:43, <david...@gmail.com> wrote:
I'm wanting the user to fil out a form in the browser, most of the fields will end up in the datastore but the user can also upload an image from a file field within the multipart form. That image will be public, i.e. not owned by them. This image will then be used by the site on various pages.

As to the blobstore, the docs recommend using Cloud Storage instead; I have not found any statements that say Cloud Storage does not work with classic app engine.

Thanks, for helping out here.


On Friday, August 12, 2016 at 11:21:38 AM UTC+10, Dave Day wrote:
Can you explain a little about what you mean by "user ownership with OAuth"? What use case are you aiming at?

The easiest way to get uploads from users in app engine is with blobstore.UploadURL and its partner blobstore.ParseUpload (https://godoc.org/google.golang.org/appengine/blobstore#UploadURL). Both of these URLs work perfectly well with the dev environment.
On 11 August 2016 at 16:58, <david...@gmail.com> wrote:
Hi, I really need some help here - I've spent ages experimenting and trying to find a good example on how to upload an image from browser to Cloud Storage that doesn't involve user ownership with oAuth, but now I've read this comment in a sample:


// NOTE: the cloud.google.com/go/storage package is not compatible with
// dev_appserver.py, so this example will not work in a local development
// environment.

I'm wondering, is it even possible? How do I write my app if I can't run on my local machine?


--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine-go+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave Day

unread,
Aug 18, 2016, 1:07:55 AM8/18/16
to david...@gmail.com, google-appengine-go
"This blob is stored in Google Cloud Storage. However, you should not manage it there. If you move, copy, or rename your blob in Google Cloud Storage, you will no longer be able to access it in Blobstore."

So now I'm a bit worried that this method is going to come back and bite me. Should I be concerned?
Only if you're planning to move, copy or rename your blob :)

Basically if you're planning to access the blobs/objects only through the google.golang.org/appengine/blobstore package then you'll be fine.

If you want to use a combination approach (by accessing GCS directly), then you will need to be more careful. For example, if you upload an object using "blobstore.UploadURL" and then move it in GCS, you may invalidate the associated appengine.BlobKey and make it unaccessible to blobstore.NewReader (for example).
Reply all
Reply to author
Forward
0 new messages