Search in sources :

Example 1 with CObjectMetadata

use of com.mendmix.cos.CObjectMetadata in project jeesuite-libs by vakinge.

the class AwsProvider method getObjectMetadata.

@Override
public CObjectMetadata getObjectMetadata(String bucketName, String fileKey) {
    GetObjectRequest getObjectRequest = GetObjectRequest.builder().bucket(bucketName).key(fileKey).build();
    ResponseInputStream<GetObjectResponse> object = s3Client.getObject(getObjectRequest);
    Map<String, String> metadata = object.response().metadata();
    if (metadata != null) {
        CObjectMetadata cObjectMetadata = new CObjectMetadata();
        cObjectMetadata.setCustomMetadatas(metadata);
        return cObjectMetadata;
    }
    return null;
}
Also used : CObjectMetadata(com.mendmix.cos.CObjectMetadata) GetObjectResponse(software.amazon.awssdk.services.s3.model.GetObjectResponse) GetObjectRequest(software.amazon.awssdk.services.s3.model.GetObjectRequest) PresignedGetObjectRequest(software.amazon.awssdk.services.s3.presigner.model.PresignedGetObjectRequest)

Example 2 with CObjectMetadata

use of com.mendmix.cos.CObjectMetadata in project jeesuite-libs by vakinge.

the class MinioProvider method getObjectMetadata.

@Override
public CObjectMetadata getObjectMetadata(String bucketName, String fileKey) {
    CObjectMetadata metadata = null;
    try {
        StatObjectResponse stat = minioClient.statObject(StatObjectArgs.builder().bucket(bucketName).object(fileKey).build());
        metadata = new CObjectMetadata();
        if (stat != null) {
            metadata.setCustomMetadatas(stat.userMetadata());
            metadata.setFilesize(stat.size());
        }
        return metadata;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : CObjectMetadata(com.mendmix.cos.CObjectMetadata) StatObjectResponse(io.minio.StatObjectResponse) JeesuiteBaseException(com.mendmix.common.JeesuiteBaseException)

Example 3 with CObjectMetadata

use of com.mendmix.cos.CObjectMetadata in project jeesuite-libs by vakinge.

the class AliyunProvider method getObjectMetadata.

@Override
public CObjectMetadata getObjectMetadata(String bucketName, String fileKey) {
    try {
        bucketName = buildBucketName(bucketName);
        fileKey = resolveFileKey(bucketName, fileKey);
        ObjectMetadata metadata = ossClient.getObjectMetadata(bucketName, fileKey);
        CObjectMetadata objectMetadata = new CObjectMetadata();
        objectMetadata.setCreateTime(metadata.getLastModified());
        objectMetadata.setMimeType(metadata.getContentType());
        objectMetadata.setFilesize(metadata.getContentLength());
        objectMetadata.setHash(metadata.getContentMD5());
        objectMetadata.setExpirationTime(metadata.getExpirationTime());
        objectMetadata.setCustomMetadatas(metadata.getUserMetadata());
        return objectMetadata;
    } catch (Exception e) {
        throw new JeesuiteBaseException(500, e.getMessage());
    }
}
Also used : CObjectMetadata(com.mendmix.cos.CObjectMetadata) JeesuiteBaseException(com.mendmix.common.JeesuiteBaseException) CObjectMetadata(com.mendmix.cos.CObjectMetadata) ObjectMetadata(com.aliyun.oss.model.ObjectMetadata) OSSException(com.aliyun.oss.OSSException) JeesuiteBaseException(com.mendmix.common.JeesuiteBaseException) IOException(java.io.IOException)

Example 4 with CObjectMetadata

use of com.mendmix.cos.CObjectMetadata in project jeesuite-libs by vakinge.

the class HuaweicloudProvider method getObjectMetadata.

@Override
public CObjectMetadata getObjectMetadata(String bucketName, String fileKey) {
    ObjectMetadata objectMetadata = obsClient.getObjectMetadata(bucketName, fileKey);
    if (objectMetadata == null) {
        return null;
    }
    CObjectMetadata result = new CObjectMetadata();
    Map<String, Object> customMetadata = objectMetadata.getMetadata();
    if (customMetadata != null) {
        Map<String, String> metadata = Maps.newHashMap();
        for (Map.Entry<String, Object> entry : customMetadata.entrySet()) {
            metadata.put(entry.getKey(), entry.getValue().toString());
        }
        result.setCustomMetadatas(metadata);
    }
    result.setMimeType(objectMetadata.getContentType());
    result.setFilesize(objectMetadata.getContentLength());
    return result;
}
Also used : CObjectMetadata(com.mendmix.cos.CObjectMetadata) ObsObject(com.obs.services.model.ObsObject) CUploadObject(com.mendmix.cos.CUploadObject) CObjectMetadata(com.mendmix.cos.CObjectMetadata) ObjectMetadata(com.obs.services.model.ObjectMetadata) Map(java.util.Map)

Example 5 with CObjectMetadata

use of com.mendmix.cos.CObjectMetadata in project jeesuite-libs by vakinge.

the class QcloudProvider method getObjectMetadata.

@Override
public CObjectMetadata getObjectMetadata(String bucketName, String fileKey) {
    try {
        String _bucketName = buildBucketName(bucketName);
        String _fileKey = resolveFileKey(bucketName, fileKey);
        ObjectMetadata metadata = cosclient.getObjectMetadata(_bucketName, _fileKey);
        CObjectMetadata objectMetadata = new CObjectMetadata();
        objectMetadata.setCreateTime(metadata.getLastModified());
        objectMetadata.setMimeType(metadata.getContentType());
        objectMetadata.setFilesize(metadata.getContentLength());
        objectMetadata.setHash(metadata.getContentMD5());
        objectMetadata.setExpirationTime(metadata.getExpirationTime());
        objectMetadata.setCustomMetadatas(metadata.getUserMetadata());
        return objectMetadata;
    } catch (Exception e) {
        throw new JeesuiteBaseException(500, buildMessage(bucketName, e));
    }
}
Also used : CObjectMetadata(com.mendmix.cos.CObjectMetadata) JeesuiteBaseException(com.mendmix.common.JeesuiteBaseException) CObjectMetadata(com.mendmix.cos.CObjectMetadata) ObjectMetadata(com.qcloud.cos.model.ObjectMetadata) CosServiceException(com.qcloud.cos.exception.CosServiceException) JeesuiteBaseException(com.mendmix.common.JeesuiteBaseException) IOException(java.io.IOException)

Aggregations

CObjectMetadata (com.mendmix.cos.CObjectMetadata)6 JeesuiteBaseException (com.mendmix.common.JeesuiteBaseException)3 IOException (java.io.IOException)2 OSSException (com.aliyun.oss.OSSException)1 ObjectMetadata (com.aliyun.oss.model.ObjectMetadata)1 CUploadObject (com.mendmix.cos.CUploadObject)1 ObjectMetadata (com.obs.services.model.ObjectMetadata)1 ObsObject (com.obs.services.model.ObsObject)1 CosServiceException (com.qcloud.cos.exception.CosServiceException)1 ObjectMetadata (com.qcloud.cos.model.ObjectMetadata)1 QiniuException (com.qiniu.common.QiniuException)1 FileInfo (com.qiniu.storage.model.FileInfo)1 StatObjectResponse (io.minio.StatObjectResponse)1 Date (java.util.Date)1 Map (java.util.Map)1 GetObjectRequest (software.amazon.awssdk.services.s3.model.GetObjectRequest)1 GetObjectResponse (software.amazon.awssdk.services.s3.model.GetObjectResponse)1 PresignedGetObjectRequest (software.amazon.awssdk.services.s3.presigner.model.PresignedGetObjectRequest)1