Thanks Vinny!
Permissions were the culprit.
On Monday, June 17, 2013 11:19:17 PM UTC-6, Vinny P wrote:
>
> Hello again Dennis,
>
> On Mon, Jun 17, 2013 at 3:36 PM, dennis wrote:
>
>> One interesting thing to note is that the file was uploaded using the
>> Cloud Console Web UI and not through app engine sdk. Could that be what's
>> causing the problem?
>>
>>
> Amusingly enough, that might be the problem. I configured my app to have
> Owner permissions over my Cloud Storage bucket - I noticed that when my app
> wrote an object in, it had full permissions to that object. If I uploaded
> an object via the Cloud Console, sometimes my app had difficulty accessing
> the object (even though my app had permissions to the bucket!).
>
> I'm interested now - I'll have to investigate more. If you need it, here's
> a simplified version of the code I used to save to Cloud Storage:
>
> String bucket = bucket name here
> String object = the filename here, including file extension
>
> GcsFilename gcs_filename = new GcsFilename(bucket, object);
>
> GcsFileOptions.Builder options_builder = new GcsFileOptions.Builder();
> options_builder = options_builder.mimeType(mime);
> //erased some options here
> GcsFileOptions options = options_builder.build();
>
> GcsOutputChannel output =
> GcsServiceFactory.createGcsService().createOrReplace(gcs_filename, options);
> output.write(ByteBuffer.wrap(data));
> output.close();
>
>
> On Mon, Jun 17, 2013 at 3:36 PM, dennis wrote:
>
>> Thanks for the fast response Vinny,
>>
>> I have also tried using
>> ServingUrlOptions.Builder.**withGoogleStorageFileName
>> with the same result of IllegalArgumentException with no error message.
>>
>> public static String getNotFoundUrl(int size) {
>> try {
>> // BlobKey blob_key =
>> BLOB_STORE.createGsBlobKey("/gs/web_content/placeholder_img.png");
>> // byte[] image_data = BLOB_STORE.fetchData(blob_key, 0, 100);
>> // Application.getLogger().warning(new String(image_data));
>> ServingUrlOptions opts =
>> ServingUrlOptions.Builder.withGoogleStorageFileName("/gs/web_content/placeholder_img.png");
>> if(size > 0) opts.imageSize(size);
>> return IMAGES_SERVICE.getServingUrl(opts);
>> } catch(IllegalArgumentException e) {
>> Application.getLogger().warning("Unable to serve placeholder image
>> from Cloud Storage.");
>> Application.getLogger().warning(e.getMessage());
>> Application.logException(e);
>> return "/placeholder_img.png";
>> }
>> }
>>
>
>
> I built a test project to verify for myself, and the following code works
> for me on production GAE.
>
> String bucket = bucket name (so web_content for your example)
> String object = object name (placeholder_img.png for your example)
>
> //Get serving url
> String gs_blob_key = "/gs/" + bucket + "/" + object;
> BlobKey blob_key =
> BlobstoreServiceFactory.getBlobstoreService().createGsBlobKey(gs_blob_key);
> ServingUrlOptions serving_options =
> ServingUrlOptions.Builder.withBlobKey(blob_key);
> String serving_url =
> ImagesServiceFactory.getImagesService().getServingUrl(serving_options);
> System.out.println("Serving URL: " + serving_url);
> resp.getWriter().println(serving_url);
>
>
>
> It's also worth double checking to see if you have permissions set
> correctly. Here's an image album showing my settings:
> http://imgur.com/a/FBhFN
>
> -----------------
> -Vinny P
> Technology & Media Advisor
> Chicago, IL
>
> My Go side project: http://invalidmail.com/
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.