@Override public long size() { return info.getSize(); }
@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(); }
this.size = blobInfo.getSize(); return this.size; } catch (StorageException exs) {
if (null == blobInfo || blobInfo.getSize() == null) { if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories(storage)) { @SuppressWarnings("unchecked")
@Test public void testToBuilder() { compareBlobs(BLOB_INFO, BLOB_INFO.toBuilder().build()); BlobInfo blobInfo = BLOB_INFO.toBuilder().setBlobId(BlobId.of("b2", "n2")).setSize(200L).build(); assertEquals("n2", blobInfo.getName()); assertEquals("b2", blobInfo.getBucket()); assertEquals(Long.valueOf(200), blobInfo.getSize()); blobInfo = blobInfo.toBuilder().setBlobId(BlobId.of("b", "n", GENERATION)).setSize(SIZE).build(); compareBlobs(BLOB_INFO, blobInfo); }
@Override public long getSize() { return this.gcsFile.getSize(); }
@Override public long getSize() { return this.gcsFile.getSize(); }
@Override public long size() { return info.getSize(); }
BlobInfoFactory() bif = New BlobInfoFactory(); BlobInfo bi = bif.loadBlobInfo(blobKey); long size = bi.getSize();
return null; if (blobInfo.getSize() > Integer.MAX_VALUE) throw new RuntimeException("This method can only process blobs up to " + Integer.MAX_VALUE + " bytes"); int blobSize = (int) blobInfo.getSize(); int chunks = (int) Math.ceil(((double) blobSize / BlobstoreService.MAX_BLOB_FETCH_SIZE)); int totalBytesRead = 0;
assertEquals(OWNER, BLOB_INFO.getOwner()); assertEquals(SELF_LINK, BLOB_INFO.getSelfLink()); assertEquals(SIZE, BLOB_INFO.getSize()); assertEquals(UPDATE_TIME, BLOB_INFO.getUpdateTime()); assertEquals(CREATE_TIME, BLOB_INFO.getCreateTime()); assertNull(DIRECTORY_INFO.getOwner()); assertNull(DIRECTORY_INFO.getSelfLink()); assertEquals(0L, (long) DIRECTORY_INFO.getSize()); assertNull(DIRECTORY_INFO.getUpdateTime()); assertTrue(DIRECTORY_INFO.isDirectory());
assertNull(blobInfo.getOwner()); assertNull(blobInfo.getSelfLink()); assertEquals(0L, (long) blobInfo.getSize()); assertNull(blobInfo.getUpdateTime()); assertNull(blobInfo.getStorageClass());
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(); }
OutputStream output = res.getOutputStream(); InputStream is = new ByteArrayInputStream(readData(blobKey,blobInfo.getSize()));
BlobInfoFactory blobInfoFactory = new BlobInfoFactory(); BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(new BlobKey("blob key")) Long blobSize = blobInfo.getSize();
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(); } }
@GET @Path("/{key}/meta") @Produces(MediaType.APPLICATION_JSON) public Response redirect(@PathParam("key") String key) throws IOException { BlobKey blobKey = new BlobKey(key); BlobInfo info = blobInfoFactory.loadBlobInfo(blobKey); String name = info.getFilename(); long size = info.getSize(); String url = "/rest/file/" + key; FileMeta meta = new FileMeta(name, size, url); List<FileMeta> meta = Lists.newArrayList(meta); EntityClass entity= new EntityClass(); entity.setFiles(meta); return Response.ok(entity).build(); }
private long fetchSize(Storage gcsStorage, BlobId file) throws IOException { final CloudStorageRetryHandler retryHandler = new CloudStorageRetryHandler(maxRetries, maxChannelReopens); while (true) { try { BlobInfo blobInfo = gcsStorage.get(file); if ( blobInfo == null ) { throw new NoSuchFileException(String.format("gs://%s/%s", file.getBucket(), file.getName())); } return blobInfo.getSize(); } catch (StorageException exs) { // Will rethrow a StorageException if all retries/reopens are exhausted retryHandler.handleStorageException(exs); // there's nothing to reopen yet, but retry even for a reopenable error. } } }