title: Create image serving URL for new Blob file
body: <p>After using the ImagesService to transform an uploaded image, I would like to store it back into a new Blob file and make it available through <code>getServingUrl()</code> as provided by the ImagesService.</p>
  
  <p>Storing the image in a new AppEngineFile as described <a href="http://code.google.com/appengine/docs/java/blobstore/overview.html#Writing_Files_to_the_Blobstore" rel="nofollow">here</a> works fine and I am able to open and view it locally using the dev server.</p>
  
  <p>However when passing the blobKey for the new AppEngineFile to <code>ImagesService.getServingUrl()</code> a </p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: Could not read blob.</p>
  </blockquote>
  
  <p>exception is thrown. Any ideas what the problem could be? This is the code I use to transform and store an uploaded image (blobKey and blobInfo correspond to the uploaded file, not the newly created one).</p>
  
  <pre><code>/* Transform image in existing Blob file */
  Image originalImage = ImagesServiceFactory.makeImageFromBlob(blobKey);
  Transform verticalFlip = ImagesServiceFactory.makeVerticalFlip();
  ImagesService imagesService = ImagesServiceFactory.getImagesService();
  Image newImage = imagesService.applyTransform(verticalFlip, originalImage);
  
  /* Store newImage in an AppEngineFile */
  FileService fileService = FileServiceFactory.getFileService();
  AppEngineFile file = fileService.createNewBlobFile(blobInfo.getContentType());
  FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
  ByteBuffer buffer = ByteBuffer.wrap(newImage.getImageData());
  writeChannel.write(buffer);
  
  /* closeFinally assigns BlobKey to new file object */
  writeChannel.closeFinally();
  BlobKey newBlobKey = fileService.getBlobKey(file);
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>The above code is correct, the problem was storing a String representation of the new blob key using <code>newBlobKey.toString()</code> instead of <code>newBlobKey.getKeyString()</code>.</p>