hmm..
well, i just looked again in the blobstore api documentation, and i
see this:

under Introducing the Blobstore:
An app can read a Blobstore value a portion at a time using an API
call. The size of the portion can be up to the maximum size of an API
return value. This size is a little less than 1 megabyte, represented
by the constant
com.google.appengine.api.blobstore.BlobstoreService.MAX_BLOB_FETCH_SIZE
in Java.

under Quotas and Limits:
maximum size of Blobstore data that can be read by the app with one
API call        1 megabyte

i already known about this limitation but didn't relate it to my
issue!!!! :(



On May 19, 2:59 am, Guss <[email protected]> wrote:
> ok..
> for all the people out there with this question open...
> after 3 days of testing and pulling my hair the answer is that it is
> possible to send the response size to the client, and it will work in
> the simplest way,
> just set the content-length header by using the method
> setContentLength.
>
> so why it didn't work for me all this time?
> the answer is simple (and annoying), google will overwrite it and
> instead will add the "Transfer-Encoding:chunked" header instead when
> the file is bigger than
> 1MB!!!!!!!
>
> i always tested it with a file which is around 5MB and that why it
> didn't work.
>
> for testing it, i used this code:
>
> public class showBlob extends HttpServlet {
>         private final BlobstoreService blobstoreService =
> BlobstoreServiceFactory.getBlobstoreService();
>         private final BlobInfoFactory blobInfoFactory = new
> BlobInfoFactory(DatastoreServiceFactory.getDatastoreService());
>
>         @Override
>         protected void doGet(HttpServletRequest request, HttpServletResponse
> response)
>                         throws IOException {
>                 BlobKey blobKey = new 
> BlobKey(request.getParameter("blob-key"));
>                 BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(blobKey);
>                 response.setContentLength(new 
> Long(blobInfo.getSize()).intValue());
>                 response.setHeader("content-type", blobInfo.getContentType());
>                 response.setHeader("content-disposition", "attachment; 
> filename=" +
>                 blobInfo.getFilename());
>                 blobstoreService.serve(blobKey, response);
>         }
>
> }
>
> and i uploaded a ziped file in the following sizes:
> 200K - worked
> 500K - worked
> 800K - worked
> 950K - worked
> 1M - failed (probably the file is a bit bigger than 1MB...)
>
> Hope this helped any one...
> and thanks to Jaroslav for being so patient and helpful...
>
> Oded.
>
> On May 16, 8:33 pm, Guss <[email protected]> wrote:
>
>
>
> > are you using resp.setHeader or resp.setContentLength ?
>
> > Thanks for all the help!!!
>
> > On May 16, 12:48 am, Jaroslav Záruba <[email protected]>
> > wrote:
>
> > > Works for 
> > > me:http://jzaruba-1.appspot.com/blob?key=AMIfv97ojheagz9LYcvrv86ROmXLdu4...
> > > Are you sure you send actual number in your header?
>
> > > On Sat, May 15, 2010 at 11:35 PM, Guss <[email protected]> wrote:
> > > > the code is working on the development environment, but not after i
> > > > deploy it to gae
>
> > > > On May 16, 12:17 am, Guss <[email protected]> wrote:
> > > > > hmmm
> > > > > not working..
> > > > > i don't know why..
>
> > > > > i run this code:
> > > > >         public void doGet(HttpServletRequest req, HttpServletResponse
> > > > resp)
> > > > >                         throws IOException {
>
> > > > >                 BlobstoreService blobstoreService =
> > > > > BlobstoreServiceFactory.getBlobstoreService();
>
> > > > >                 Iterator<BlobInfo> iterator = new
> > > > > BlobInfoFactory().queryBlobInfos();
>
> > > > >                 while(iterator.hasNext()) {
> > > > >                   BlobInfo b = iterator.next();
> > > > >                   if (b.getFilename().equals("myfile.exe")) {
> > > > >                           resp.setHeader("content-type",
> > > > b.getContentType());
> > > > >                           resp.setHeader("content-disposition",
> > > > "attachment; filename=" +
> > > > > b.getFilename());
> > > > >                           resp.setHeader("content-length", new
> > > > > Long(b.getSize()).toString());
> > > > >                           resp.setContentLength(new
> > > > Long(b.getSize()).intValue());
> > > > >                           blobstoreService.serve(b.getBlobKey(),resp);
> > > > >                   }
> > > > >                 }
> > > > >         }
>
> > > > > and got this response header (using firebug)
> > > > > HTTP/1.1 200 OK
> > > > > Content-Type: application/x-msdownload
> > > > > Content-Disposition: attachment; filename=myfile.exe
> > > > > Date: Sat, 15 May 2010 21:14:16 GMT
> > > > > Server: Google Frontend
> > > > > Transfer-Encoding:chunked
>
> > > > > On May 15, 10:49 pm, Jaroslav Záruba <[email protected]>
> > > > > wrote:
>
> > > > > > Weird... Maybe it is the non-capitals in the header name? I'm not 
> > > > > > sure
> > > > > > whether it shouldn't be rather "Content-Length", instead of
> > > > > > "content-length". Maybe you cold try
> > > > > > response.setContentLength(size)
>
> > > > > > this is exact copy'n'paste from my code:
> > > > > > --
> > > > > > BlobKey blobKey = new BlobKey(request.getParameter("key"));
>
> > > > > > BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(blobKey);
> > > > > > response.setContentLength(new Long(blobInfo.getSize()).intValue());
> > > > > > response.setHeader("content-type", blobInfo.getContentType());
> > > > > > response.setHeader("content-disposition", "attachment; filename=" +
> > > > > > blobInfo.getFilename());
>
> > > > > > blobstoreService.serve(blobKey, response);
> > > > > > --
> > > > > > ...both Firebug and Live HTTP headers show the header (with proper
> > > > value)...
>
> > > > > > hope it helps
>
> > > > > > On Sat, May 15, 2010 at 9:00 PM, Guss <[email protected]> wrote:
> > > > > > > one more thing,
> > > > > > > i used httpfox to check the response header, and "content-length"
> > > > > > > header is not sent in the response..
>
> > > > > > > On May 15, 8:28 pm, Jaroslav Záruba <[email protected]>
> > > > wrote:
> > > > > > > > Hi
>
> > > > > > > > --
> > > > > > > > BlobInfoFactory blobInfoFactory = new
> > > > > > > > BlobInfoFactory(DatastoreServiceFactory.getDatastoreService());
> > > > > > > > BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(blobKey);
> > > > > > > > long blobSize = blobInfo.getSize();
> > > > > > > > response.setHeader("content-length", new
> > > > Long(blobSize).toString());
> > > > > > > > --
>
> > > > > > > > Is this what you mean?
>
> > > > > > > > Regards
> > > > > > > >   J. Záruba
>
> > > > > > > > On Sat, May 15, 2010 at 6:38 PM, Guss <[email protected]>
> > > > wrote:
> > > > > > > > > Hi,
> > > > > > > > > I'm using java in GAE and i recently started using Blobstore 
> > > > > > > > > to
> > > > serve
> > > > > > > > > my application download file, the only "issue" that i have is
> > > > that
> > > > > > > > > when it serves the file
> > > > > > > > > the size is not sent to the browser so it can't estimate the 
> > > > > > > > > time
> > > > for
> > > > > > > > > the download to complete...
>
> > > > > > > > > here is the piece of code that i use to serve the file:
> > > > > > > > >                BlobstoreService blobstoreService =
> > > > > > > > > BlobstoreServiceFactory.getBlobstoreService();
>
> > > > > > > > >                Iterator<BlobInfo> iterator = new
> > > > > > > > > BlobInfoFactory().queryBlobInfos();
>
> > > > > > > > >                while(iterator.hasNext()) {
> > > > > > > > >                  BlobInfo b = iterator.next();
> > > > > > > > >                  if (b.getFilename().equals('myfile.exe'))
>
> > > >  blobstoreService.serve(b.getBlobKey(),resp);
> > > > > > > > >                }
>
> > > > > > > > > is there a way to also send the file size to the browser while
> > > > serving
> > > > > > > > > the file?
>
> > > > > > > > > thanks,
> > > > > > > > > Oded.
>
> > > > > > > > > --
> > > > > > > > > You received this message because you are subscribed to the
> > > > Google
> > > > > > > Groups
> > > > > > > > > "Google App Engine" group.
> > > > > > > > > To post to this group, send email to
> > > > [email protected]
> > > > > > > .
> > > > > > > > > To unsubscribe from this group, send email to
> > > > > > > > > [email protected]<google-appengine%2Bunsubscrib
> > > > > > > > >  [email protected]><google-appengine%2Bunsubscrib
> > > > [email protected]><google-appengine%2Bunsubscrib
> > > > > > > [email protected]>
> > > > > > > > > .
> > > > > > > > > For more options, visit this group at
> > > > > > > > >http://groups.google.com/group/google-appengine?hl=en.
>
> > > > > > > > --
> > > > > > > > You received this message because you are subscribed to the 
> > > > > > > > Google
> > > > Groups
> > > > > > > "Google App Engine" group.
> > > > > > > > To post to this group, send email to
> > > > [email protected].
> > > > > > > > To unsubscribe from this group, send email to
> > > > > > > [email protected]<google-appengine%2Bunsubscrib
> > > > > > >  [email protected]><google-appengine%2Bunsubscrib
> > > > [email protected]>
> > > > > > > .
> > > > > > > > For more options, visit this group athttp://
> > > > > > > groups.google.com/group/google-appengine?hl=en.
>
> > > > > > > --
> > > > > > > You received this message because you are subscribed to the Google
> > > > Groups
> > > > > > > "Google App Engine" group.
> > > > > > > To post to this group, send email to
> > > > [email protected].
> > > > > > > To unsubscribe from this group, send email to
> > > > > > > [email protected]<google-appengine%2Bunsubscrib
> > > > > > >  [email protected]><google-appengine%2Bunsubscrib
> > > > [email protected]>
> > > > > > > .
> > > > > > > For more options, visit this group at
> > > > > > >http://groups.google.com/group/google-appengine?hl=en.
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > Groups "Google App Engine" group.
> > > > > > To post to this group, send email to 
> > > > > > [email protected]
> > > > .
> > > > > > To unsubscribe from this group, send email to
> > > > [email protected]<google-appengine%2Bunsubscrib
> > > >  [email protected]>
> > > > .
> > > > > > For more options, visit this group athttp://
> > > > groups.google.com/group/google-appengine?hl=en.
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google 
> > > > > Groups
> > > > "Google App Engine" group.
> > > > > To post to this group, send email to 
> > > > > [email protected].
> > > > > To unsubscribe from this group, send email to...
>
> read more »

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to