Search in sources :

Example 1 with OssFile

use of org.springblade.core.oss.model.OssFile in project blade-tool by chillzhuang.

the class AliossTemplate method statFile.

@SneakyThrows
public OssFile statFile(String bucketName, String fileName) {
    ObjectMetadata stat = ossClient.getObjectMetadata(getBucketName(bucketName), fileName);
    OssFile ossFile = new OssFile();
    ossFile.setName(fileName);
    ossFile.setLink(fileLink(ossFile.getName()));
    ossFile.setHash(stat.getContentMD5());
    ossFile.setLength(stat.getContentLength());
    ossFile.setPutTime(stat.getLastModified());
    ossFile.setContentType(stat.getContentType());
    return ossFile;
}
Also used : OssFile(org.springblade.core.oss.model.OssFile) ObjectMetadata(com.aliyun.oss.model.ObjectMetadata) SneakyThrows(lombok.SneakyThrows)

Example 2 with OssFile

use of org.springblade.core.oss.model.OssFile in project blade-tool by chillzhuang.

the class QiniuTemplate method statFile.

@SneakyThrows
public OssFile statFile(String bucketName, String fileName) {
    FileInfo stat = bucketManager.stat(getBucketName(bucketName), fileName);
    OssFile ossFile = new OssFile();
    ossFile.setName(stat.key);
    ossFile.setName(Func.isEmpty(stat.key) ? fileName : stat.key);
    ossFile.setLink(fileLink(ossFile.getName()));
    ossFile.setHash(stat.hash);
    ossFile.setLength(stat.fsize);
    ossFile.setPutTime(new Date(stat.putTime / 10000));
    ossFile.setContentType(stat.mimeType);
    return ossFile;
}
Also used : FileInfo(com.qiniu.storage.model.FileInfo) OssFile(org.springblade.core.oss.model.OssFile) Date(java.util.Date) SneakyThrows(lombok.SneakyThrows)

Aggregations

SneakyThrows (lombok.SneakyThrows)2 OssFile (org.springblade.core.oss.model.OssFile)2 ObjectMetadata (com.aliyun.oss.model.ObjectMetadata)1 FileInfo (com.qiniu.storage.model.FileInfo)1 Date (java.util.Date)1