Search in sources :

Example 1 with Builder

use of com.google.cloud.storage.BlobInfo.Builder in project pratilipi by Pratilipi.

the class BlobAccessorGcsImpl2 method createOrUpdateBlob.

@Override
public BlobEntry createOrUpdateBlob(BlobEntry blobEntry) {
    BlobId blobId = BlobId.of(bucketName, blobEntry.getName());
    Builder blobInfoBuilder = BlobInfo.newBuilder(blobId);
    if (blobEntry.getMimeType() != null)
        blobInfoBuilder.setContentType(blobEntry.getMimeType());
    if (blobEntry.getCacheControl() != null)
        blobInfoBuilder.setCacheControl(blobEntry.getCacheControl());
    if (blobEntry.getMetaName() != null) {
        Map<String, String> metadata = new HashMap<>();
        metadata.put(BlobEntry.META_NAME, blobEntry.getMetaName());
        blobInfoBuilder.setMetadata(metadata);
    }
    return new BlobEntryGcsImpl(gcsService.create(blobInfoBuilder.build(), blobEntry.getData()));
}
Also used : HashMap(java.util.HashMap) Builder(com.google.cloud.storage.BlobInfo.Builder) BlobEntryGcsImpl(com.pratilipi.data.type.gcs.BlobEntryGcsImpl) BlobId(com.google.cloud.storage.BlobId)

Aggregations

BlobId (com.google.cloud.storage.BlobId)1 Builder (com.google.cloud.storage.BlobInfo.Builder)1 BlobEntryGcsImpl (com.pratilipi.data.type.gcs.BlobEntryGcsImpl)1 HashMap (java.util.HashMap)1