本文整理汇总了Java中com.google.api.services.storage.model.StorageObject.getMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java StorageObject.getMetadata方法的具体用法?Java StorageObject.getMetadata怎么用?Java StorageObject.getMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.services.storage.model.StorageObject
的用法示例。
在下文中一共展示了StorageObject.getMetadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toFile
import com.google.api.services.storage.model.StorageObject; //导入方法依赖的package包/类
private FileHeader toFile(StorageObject object) {
String name = object.getName();
Preconditions.checkArgument(name.startsWith(filePrefix));
name = name.substring(filePrefix.length());
return new FileHeader(
name,
HashCode.fromBytes(BaseEncoding.base64().decode(object.getMd5Hash())),
object.getSize().intValueExact(),
object.getMetadata());
}
示例2: createItemInfoForStorageObject
import com.google.api.services.storage.model.StorageObject; //导入方法依赖的package包/类
/**
* Helper for converting a StorageResourceId + StorageObject into a GoogleCloudStorageItemInfo.
*/
public static GoogleCloudStorageItemInfo createItemInfoForStorageObject(
StorageResourceId resourceId, StorageObject object) {
Preconditions.checkArgument(resourceId != null, "resourceId must not be null");
Preconditions.checkArgument(object != null, "object must not be null");
Preconditions.checkArgument(
resourceId.isStorageObject(),
"resourceId must be a StorageObject. resourceId: %s",
resourceId);
Preconditions.checkArgument(
resourceId.getBucketName().equals(object.getBucket()),
"resourceId.getBucketName() must equal object.getBucket(): '%s' vs '%s'",
resourceId.getBucketName(), object.getBucket());
Preconditions.checkArgument(
resourceId.getObjectName().equals(object.getName()),
"resourceId.getObjectName() must equal object.getName(): '%s' vs '%s'",
resourceId.getObjectName(), object.getName());
Map<String, byte[]> decodedMetadata =
object.getMetadata() == null ? null : decodeMetadata(object.getMetadata());
byte[] md5Hash = null;
byte[] crc32c = null;
if (!Strings.isNullOrEmpty(object.getCrc32c())) {
crc32c = BaseEncoding.base64().decode(object.getCrc32c());
}
if (!Strings.isNullOrEmpty(object.getMd5Hash())) {
md5Hash = BaseEncoding.base64().decode(object.getMd5Hash());
}
// GCS API does not make available location and storage class at object level at present
// (it is same for all objects in a bucket). Further, we do not use the values for objects.
// The GoogleCloudStorageItemInfo thus has 'null' for location and storage class.
return new GoogleCloudStorageItemInfo(
resourceId,
object.getUpdated().getValue(),
object.getSize().longValue(),
null,
null,
object.getContentType(),
decodedMetadata,
object.getGeneration(),
object.getMetageneration(),
new VerificationAttributes(md5Hash, crc32c));
}