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.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
@ -149,4 +151,21 @@ public class File extends Model<File> {
|
|||||||
return this.id;
|
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 String fileName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件大小
|
||||||
|
*/
|
||||||
|
private Long fileSize;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,4 +30,9 @@ public class SignUrlDownloadResponse {
|
|||||||
*/
|
*/
|
||||||
private String fileName;
|
private String fileName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件大小
|
||||||
|
*/
|
||||||
|
private Long fileSize;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -981,6 +981,7 @@ public class FileServiceImpl implements FileService {
|
|||||||
.signUrl(this.fileManager.buildPublicXImageProcess(url, style))
|
.signUrl(this.fileManager.buildPublicXImageProcess(url, style))
|
||||||
.fileKey(item.getFileUuid())
|
.fileKey(item.getFileUuid())
|
||||||
.fileName(item.getFileName())
|
.fileName(item.getFileName())
|
||||||
|
.fileSize(item.fetchFileSize())
|
||||||
.build();
|
.build();
|
||||||
case PRIVATE_BUCKET://私有桶 - 临时授权链接 例如 http://xxx.png?Expire=a&AccessKeyId=b&Signature=c&repsonse-content-disposition=d
|
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);
|
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))
|
.signUrl(UrlUtil.httpToHttps(signUrl))
|
||||||
.fileKey(item.getFileUuid())
|
.fileKey(item.getFileUuid())
|
||||||
.fileName(item.getFileName())
|
.fileName(item.getFileName())
|
||||||
|
.fileSize(item.fetchFileSize())
|
||||||
.build();
|
.build();
|
||||||
default:
|
default:
|
||||||
BizException.error(CodeEnum.CHANNEL_TYPE_NOT_EXIST);
|
BizException.error(CodeEnum.CHANNEL_TYPE_NOT_EXIST);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user