Assert.check(expectedBytes == bytes.length, "Expected %s bytes, got %s: %s",
expectedBytes, bytes.length, prettyBytes(bytes));
}
final AppEngineFile file = dump(mimeType, filename, ByteBuffer.wrap(bytes));
log.info("Wrote file " + file);
BlobKey blobKey =
// NOTE(ohler): When running locally with unapplied jobs
// enabled, getBlobKey() sometimes returns null here even
// though it shouldn't, according to its documentation. So
// we retry. Not sure if this is needed when deployed.
new RetryHelper().run(
new RetryHelper.Body<BlobKey>() {
@Override public BlobKey run() throws RetryableFailure {
BlobKey key = getFileService().getBlobKey(file);
if (key != null) {
return key;
} else {
throw new RetryableFailure("getBlobKey(" + file + ") returned null");
}