feat:(REQ-3560) 获取下载文件加上文件大小
This commit is contained in:
parent
215845e73a
commit
89a2ce5a5d
@ -7,6 +7,8 @@ import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
@ -149,4 +151,21 @@ public class File extends Model<File> {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Long fetchFileSize() {
|
||||
if (Objects.isNull(this.getStorageSize()) || Objects.isNull(this.getStorageUnit())) {
|
||||
return 0L;
|
||||
}
|
||||
|
||||
if (this.getStorageUnit().equalsIgnoreCase("b")) {
|
||||
return this.getStorageSize().longValue();
|
||||
}
|
||||
if (this.getStorageUnit().equalsIgnoreCase("kb")) {
|
||||
return this.getStorageSize().longValue() * 1024L;
|
||||
}
|
||||
if (this.getStorageUnit().equalsIgnoreCase("mb")) {
|
||||
return this.getStorageSize().longValue() * 1024 * 1024L;
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,4 +29,9 @@ public class ApiSignUrlDownloadResponse {
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
private Long fileSize;
|
||||
|
||||
}
|
||||
|
||||
@ -30,4 +30,9 @@ public class SignUrlDownloadResponse {
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
private Long fileSize;
|
||||
|
||||
}
|
||||
|
||||
@ -981,6 +981,7 @@ public class FileServiceImpl implements FileService {
|
||||
.signUrl(this.fileManager.buildPublicXImageProcess(url, style))
|
||||
.fileKey(item.getFileUuid())
|
||||
.fileName(item.getFileName())
|
||||
.fileSize(item.fetchFileSize())
|
||||
.build();
|
||||
case PRIVATE_BUCKET://私有桶 - 临时授权链接 例如 http://xxx.png?Expire=a&AccessKeyId=b&Signature=c&repsonse-content-disposition=d
|
||||
String signUrl = this.fileManager.signUrlDownload(item.getBucketName(), tgtFileKey, Objects.nonNull(expire) ? expire : SIGN_URL_DOWNLOAD_EXPIRE_SECOND , item.getChannelCode(), item.getFileName(), style, hasFileName);
|
||||
@ -988,6 +989,7 @@ public class FileServiceImpl implements FileService {
|
||||
.signUrl(UrlUtil.httpToHttps(signUrl))
|
||||
.fileKey(item.getFileUuid())
|
||||
.fileName(item.getFileName())
|
||||
.fileSize(item.fetchFileSize())
|
||||
.build();
|
||||
default:
|
||||
BizException.error(CodeEnum.CHANNEL_TYPE_NOT_EXIST);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user