Search in sources :

Example 1 with CObjectMetadata

use of com.jeesuite.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.jeesuite.cos.CObjectMetadata) StatObjectResponse(io.minio.StatObjectResponse) JeesuiteBaseException(com.jeesuite.common.JeesuiteBaseException)

Example 2 with CObjectMetadata

use of com.jeesuite.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.jeesuite.cos.CObjectMetadata) JeesuiteBaseException(com.jeesuite.common.JeesuiteBaseException) ObjectMetadata(com.qcloud.cos.model.ObjectMetadata) CObjectMetadata(com.jeesuite.cos.CObjectMetadata) CosServiceException(com.qcloud.cos.exception.CosServiceException) IOException(java.io.IOException) JeesuiteBaseException(com.jeesuite.common.JeesuiteBaseException)

Example 3 with CObjectMetadata

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

the class QiniuProvider method getObjectMetadata.

@Override
public CObjectMetadata getObjectMetadata(String bucketName, String fileKey) {
    try {
        bucketName = buildBucketName(bucketName);
        FileInfo stat = bucketManager.stat(bucketName, fileKey);
        CObjectMetadata objectMetadata = new CObjectMetadata();
        objectMetadata.setCreateTime(new Date(stat.putTime));
        objectMetadata.setFilesize(stat.fsize);
        objectMetadata.setHash(stat.md5);
        objectMetadata.setMimeType(stat.mimeType);
        return objectMetadata;
    } catch (QiniuException e) {
        processQiniuException(bucketName, e);
        return null;
    }
}
Also used : CObjectMetadata(com.jeesuite.cos.CObjectMetadata) QiniuException(com.qiniu.common.QiniuException) FileInfo(com.qiniu.storage.model.FileInfo) Date(java.util.Date)

Example 4 with CObjectMetadata

use of com.jeesuite.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.jeesuite.cos.CObjectMetadata) JeesuiteBaseException(com.jeesuite.common.JeesuiteBaseException) ObjectMetadata(com.aliyun.oss.model.ObjectMetadata) CObjectMetadata(com.jeesuite.cos.CObjectMetadata) OSSException(com.aliyun.oss.OSSException) IOException(java.io.IOException) JeesuiteBaseException(com.jeesuite.common.JeesuiteBaseException)

Aggregations

CObjectMetadata (com.jeesuite.cos.CObjectMetadata)4 JeesuiteBaseException (com.jeesuite.common.JeesuiteBaseException)3 IOException (java.io.IOException)2 OSSException (com.aliyun.oss.OSSException)1 ObjectMetadata (com.aliyun.oss.model.ObjectMetadata)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