Java Code Examples for com.google.cloud.storage.Blob#getSize()
The following examples show how to use
com.google.cloud.storage.Blob#getSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GcsRepository.java From hawkbit-extensions with Eclipse Public License 1.0 | 6 votes |
@Override public AbstractDbArtifact getArtifactBySha1(final String tenant, final String sha1Hash) { final String key = objectKey(tenant, sha1Hash); LOG.info("Retrieving GCS object from bucket {} and key {}", gcsProperties.getBucketName(), key); final Blob blob = gcsStorage.get(gcsProperties.getBucketName(), key); if (blob == null || !blob.exists()) { return null; } // the MD5Content is stored in the ETag return new GcsArtifact(gcsStorage, gcsProperties, key, sha1Hash, new DbArtifactHash(sha1Hash, BaseEncoding.base16().lowerCase().encode(BaseEncoding.base64().decode(blob.getMd5())), null), blob.getSize(), blob.getContentType()); }
Example 2
Source File: StorageObjectSummary.java From snowflake-jdbc with Apache License 2.0 | 5 votes |
/** * createFromGcsBlob creates a StorageObjectSummary from a GCS blob object * * @param blob GCS blob object * @return a new StorageObjectSummary */ public static StorageObjectSummary createFromGcsBlob(Blob blob) { String bucketName = blob.getBucket(); String path = blob.getName(); String hexMD5 = blob.getMd5ToHexString(); long size = blob.getSize(); return new StorageObjectSummary(bucketName, path, hexMD5, size); }
Example 3
Source File: SnowflakeGCSClient.java From snowflake-jdbc with Apache License 2.0 | 5 votes |
@Override public StorageObjectMetadata getObjectMetadata(String remoteStorageLocation, String prefix) throws StorageProviderException { try { BlobId blobId = BlobId.of(remoteStorageLocation, prefix); Blob blob = gcsClient.get(blobId); // GCS returns null if the blob was not found // By design, our storage platform expects to see a "blob not found" situation // as a RemoteStorageProviderException // Hence, we throw a RemoteStorageProviderException if (blob == null) { throw new StorageProviderException( new StorageException( 404, // because blob not found "Blob" + blobId.getName() + " not found in bucket " + blobId.getBucket()) ); } return new CommonObjectMetadata(blob.getSize(), blob.getContentEncoding(), blob.getMetadata()); } catch (StorageException ex) { throw new StorageProviderException(ex); } }
Example 4
Source File: GoogleCloudStorageSource.java From datacollector with Apache License 2.0 | 5 votes |
private boolean isBlobEligible(Blob blob, long minTimeStamp, String currentBlobGeneratedId, String currentFileOffset) { String blobName = blob.getName(); String prefixToMatch = blobName.substring( GcsUtil.normalizePrefix(gcsOriginConfig.commonPrefix).length(), blobName.length()); return blob.getSize() > 0 && //blob update time > current offset time (blob.getUpdateTime() > minTimeStamp //blob offset time = current offset time, but lexicographically greater than current offset || (blob.getUpdateTime() == minTimeStamp && blob.getGeneratedId().compareTo(currentBlobGeneratedId) > 0) //blob id same as current id and did not read till end of the file || blob.getGeneratedId().equals(currentBlobGeneratedId) && !END_FILE_OFFSET.equals(currentFileOffset)) && antPathMatcher.match(gcsOriginConfig.prefixPattern, prefixToMatch); }
Example 5
Source File: GcsPinotFS.java From incubator-pinot with Apache License 2.0 | 5 votes |
@Override public long length(URI fileUri) throws IOException { try { checkState(!isPathTerminatedByDelimiter(fileUri), "URI is a directory"); Blob blob = getBucket(fileUri).get(fileUri.getPath()); checkState(existsBlob(blob), "File '%s' does not exist", fileUri); return blob.getSize(); } catch (Throwable t) { throw new IOException(t); } }
Example 6
Source File: BigQuery.java From gcp-ingestion with Mozilla Public License 2.0 | 4 votes |
@Override protected long getByteSize(Blob input) { return input.getSize(); }
Example 7
Source File: GoogleTempFileStore.java From data-transfer-project with Apache License 2.0 | 4 votes |
InputStreamWrapper getStream(UUID jobId, String keyName) { String blobName = getDataKeyName(jobId, keyName); Blob blob = bucket.get(blobName); ReadChannel channel = blob.reader(); return new InputStreamWrapper(Channels.newInputStream(channel), blob.getSize()); }