@Override public Optional<String> mimeType() { return Optional.fromNullable(info.getContentType()); }
@Override public String toString() { return MoreObjects.toStringHelper(this) .add("bucket", getBucket()) .add("name", getName()) .add("generation", getGeneration()) .add("size", getSize()) .add("content-type", getContentType()) .add("metadata", getMetadata()) .toString(); }
checkArgument(blobInfo.getContentType() != null, "Blob is missing a value for content-type"); signatureInfoBuilder.setContentType(blobInfo.getContentType());
.append('\n') .append('\n') .append(BLOB_INFO1.getContentType()) .append('\n') .append(42L + 1209600)
.append(BLOB_INFO1.getMd5()) .append('\n') .append(BLOB_INFO1.getContentType()) .append('\n') .append(42L + 1209600)
.append('\n') .append('\n') .append(BLOB_INFO1.getContentType()) .append('\n') .append(42L + 1209600)
.append(BLOB_INFO1.getMd5()) .append('\n') .append(BLOB_INFO1.getContentType()) .append('\n') .append(42L + 1209600)
@Test public void testCreateBlobStream() { String blobName = "test-create-blob-stream"; BlobInfo blob = BlobInfo.newBuilder(BUCKET, blobName).setContentType(CONTENT_TYPE).build(); ByteArrayInputStream stream = new ByteArrayInputStream(BLOB_STRING_CONTENT.getBytes(UTF_8)); Blob remoteBlob = storage.create(blob, stream); assertNotNull(remoteBlob); assertEquals(blob.getBucket(), remoteBlob.getBucket()); assertEquals(blob.getName(), remoteBlob.getName()); assertEquals(blob.getContentType(), remoteBlob.getContentType()); byte[] readBytes = storage.readAllBytes(BUCKET, blobName); assertEquals(BLOB_STRING_CONTENT, new String(readBytes, UTF_8)); }
tgtInfoBuilder.setContentType(blobInfo.getContentType());
assertEquals(sourceBlob2.getBucket(), remoteUpdatedBlob2.getBucket()); assertEquals(sourceBlob2.getName(), remoteUpdatedBlob2.getName()); assertEquals(updatedBlob2.getContentType(), remoteUpdatedBlob2.getContentType());
assertEquals(sourceBlob2.getBucket(), remoteUpdatedBlob2.getBucket()); assertEquals(sourceBlob2.getName(), remoteUpdatedBlob2.getName()); assertEquals(updatedBlob1.getContentType(), remoteUpdatedBlob1.getContentType()); assertEquals(updatedBlob2.getContentType(), remoteUpdatedBlob2.getContentType());
assertEquals(expected.getAcl(), value.getAcl()); assertEquals(expected.getComponentCount(), value.getComponentCount()); assertEquals(expected.getContentType(), value.getContentType()); assertEquals(expected.getCacheControl(), value.getCacheControl()); assertEquals(expected.getContentDisposition(), value.getContentDisposition());
@Override public Optional<String> mimeType() { return Optional.fromNullable(info.getContentType()); }
assertEquals(ACL, BLOB_INFO.getAcl()); assertEquals(COMPONENT_COUNT, BLOB_INFO.getComponentCount()); assertEquals(CONTENT_TYPE, BLOB_INFO.getContentType()); assertEquals(CACHE_CONTROL, BLOB_INFO.getCacheControl()); assertEquals(CONTENT_DISPOSITION, BLOB_INFO.getContentDisposition()); assertNull(DIRECTORY_INFO.getAcl()); assertNull(DIRECTORY_INFO.getComponentCount()); assertNull(DIRECTORY_INFO.getContentType()); assertNull(DIRECTORY_INFO.getCacheControl()); assertNull(DIRECTORY_INFO.getContentDisposition());
BlobKey blobKey = new BlobKey(key); BlobInfo blobInfo = new BlobInfoFactory().loadBlobInfo(blobKey); // set response header response.setContentType(blobInfo.getContentType()); response.setHeader("Content-Disposition", "filename=" + blobInfo.getFilename()); // serve blob blobService.serve(blobKey, response);
assertNull(blobInfo.getAcl()); assertNull(blobInfo.getComponentCount()); assertNull(blobInfo.getContentType()); assertNull(blobInfo.getCacheControl()); assertNull(blobInfo.getContentDisposition());
BlobInfoFactory blobInfoFactory = new BlobInfoFactory(DatastoreServiceFactory.getDatastoreService()); BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(blobKey); resp.setContentLength(new Long(blobInfo.getSize()).intValue()); resp.setHeader("content-type", blobInfo.getContentType()); resp.setHeader("content-disposition", "attachment;filename=" + blobInfo.getFilename()); blobstoreService.serve(blobKey, resp);
@Override public String toString() { return MoreObjects.toStringHelper(this) .add("bucket", getBucket()) .add("name", getName()) .add("generation", getGeneration()) .add("size", getSize()) .add("content-type", getContentType()) .add("metadata", getMetadata()) .toString(); }
BlobInfoFactory bif = new BlobInfoFactory(); BlobKey bk = new BlobKey("<your blobkey>"); BlobInfo blobInfo = bif.loadBlobInfo(bk); if(blobInfo == null) // The blob with the provided blobkey does not exists else String contentType = blobInfo.getContentType();
Map<String, List<BlobInfo>> blobsData = blobstoreService.getBlobInfos(request); for (String key : blobsData.keySet()) { for(BlobInfo blob:blobsData.get(key)) { byte[] b = new byte[(int)blob.getSize()]; BlobstoreInputStream in = new BlobstoreInputStream(blob.getBlobKey()); in.read(b); GcsService gcsService = GcsServiceFactory.createGcsService(); GcsFilename filename = new GcsFilename(BUCKETNAME, "/testFolder3/"+blob.getFilename()); GcsFileOptions options = new GcsFileOptions.Builder() .mimeType(blob.getContentType()) .acl("authenticated-read") .addUserMetadata("myfield1", "my field value") .build(); gcsService.createOrReplace(filename, options,ByteBuffer.wrap(b)); in.close(); } }