All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.fscode.commons.minio.manager.MinioMultiPartUploadManager Maven / Gradle / Ivy

There is a newer version: 1.0.1
Show newest version
package cn.fscode.commons.minio.manager;

import cn.hutool.http.HttpRequest;
import cn.fscode.commons.minio.utils.MinioUtils;
import cn.fscode.commons.storage.api.config.MinioStorageProperties;
import cn.fscode.commons.storage.api.partupload.MultiPartUploadInit;
import cn.fscode.commons.storage.api.partupload.MultiPartUploadService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.File;

/**
 * @author shenguangyang
 */
@Component
public class MinioMultiPartUploadManager implements MultiPartUploadService {
    @Resource
    private MinioStorageProperties minioStorageProperties;
    @Override
    public MultiPartUploadInit init(String objectName, int totalPart) {
        return MinioUtils.MultiPartUpload.init(minioStorageProperties.getBucketName(), objectName, totalPart);
    }


    @Override
    public void uploadPart(String uploadUrl,String contentType, File file) {
        HttpRequest.put(uploadUrl)
                .contentType(contentType)
                .form("key", file)
                .execute();
    }

    @Override
    public void merge(String objectName, String uploadId) {
        MinioUtils.MultiPartUpload.merge(minioStorageProperties.getBucketName(), objectName,uploadId);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy