mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 12:18:42 +08:00 
			
		
		
		
	修复上传七牛云无mime type问题
This commit is contained in:
		@@ -22,7 +22,7 @@ public interface FileClient {
 | 
			
		||||
     * @return 完整路径,即 HTTP 访问地址
 | 
			
		||||
     * @throws Exception 上传文件时,抛出 Exception 异常
 | 
			
		||||
     */
 | 
			
		||||
    String upload(byte[] content, String path) throws  Exception;
 | 
			
		||||
    String upload(byte[] content, String path, String type) throws  Exception;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除文件
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,7 @@ public class DBFileClient extends AbstractFileClient<DBFileClientConfig> {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String upload(byte[] content, String path) {
 | 
			
		||||
    public String upload(byte[] content, String path, String type) {
 | 
			
		||||
        getDao().insert(getId(), path, content);
 | 
			
		||||
        // 拼接返回路径
 | 
			
		||||
        return super.formatFileUrl(config.getDomain(), path);
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@ public class FtpFileClient extends AbstractFileClient<FtpFileClientConfig> {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String upload(byte[] content, String path) {
 | 
			
		||||
    public String upload(byte[] content, String path, String type) {
 | 
			
		||||
        // 执行写入
 | 
			
		||||
        String filePath = getFilePath(path);
 | 
			
		||||
        String fileName = FileUtil.getName(filePath);
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@ public class LocalFileClient extends AbstractFileClient<LocalFileClientConfig> {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String upload(byte[] content, String path) {
 | 
			
		||||
    public String upload(byte[] content, String path, String type) {
 | 
			
		||||
        // 执行写入
 | 
			
		||||
        String filePath = getFilePath(path);
 | 
			
		||||
        FileUtil.writeBytes(content, filePath);
 | 
			
		||||
 
 | 
			
		||||
@@ -82,10 +82,11 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String upload(byte[] content, String path) throws Exception {
 | 
			
		||||
    public String upload(byte[] content, String path, String type) throws Exception {
 | 
			
		||||
        // 执行上传
 | 
			
		||||
        client.putObject(PutObjectArgs.builder()
 | 
			
		||||
                .bucket(config.getBucket()) // bucket 必须传递
 | 
			
		||||
                .contentType(type)
 | 
			
		||||
                .object(path) // 相对路径作为 key
 | 
			
		||||
                .stream(new ByteArrayInputStream(content), content.length, -1) // 文件内容
 | 
			
		||||
                .build());
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@ public class SftpFileClient extends AbstractFileClient<SftpFileClientConfig> {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String upload(byte[] content, String path) {
 | 
			
		||||
    public String upload(byte[] content, String path, String type) {
 | 
			
		||||
        // 执行写入
 | 
			
		||||
        String filePath = getFilePath(path);
 | 
			
		||||
        File file = FileUtils.createTempFile(content);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user