in my app i need to do the following: 1. a zip file with images (jpgs
only right now)and other stuff is uploaded into the BlobStore. 2. an
app engine backend should read the entries from the uploaded zip and
save all images found inside to the BlobStore as stand alone files.

i successfully upload, unzip and save files @ blobstore, but the
images seem to be broken. when i download them from the BlobStore
(simply blobstoreService.serve them) the images have wrong colors, or
displayed partially, or broken in other ways. an attempt to use
ImagesService also throws an exception. i checked the size of the
images before they are zipped and the size of the files unzipped while
written into the blobstore and they look the same. here is my code:

ZipInputStream zis = ...;
ZipEntry entry;
while ((entry =zis.getNextEntry()) !=null)
{
    String fileName = entry.getName().toLowerCase();
    if(fileName.indexOf(".jpg") != -1 || fileName.indexOf(".jpeg") !=
-1)
     {
        FileService fileService = FileServiceFactory.getFileService();
        String mime = ctx.getMimeType(fileName);//getting mime from
servlet context
        AppEngineFile file = fileService.createNewBlobFile(mime,
fileName);
        boolean lock = true;
        FileWriteChannel writeChannel =
fileService.openWriteChannel(file, lock);
        byte[] buffer = new
byte[BlobstoreService.MAX_BLOB_FETCH_SIZE];
        while(zis.read(buffer) >= 0)
        {
           ByteBuffer bb = ByteBuffer.wrap(buffer);
           writeChannel.write(bb);
        }
        writeChannel.closeFinally();
        BlobKey coverKey =  fileService.getBlobKey(file);
        ....
     }
}

thanks a lot for you time!

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

Reply via email to