Giter Site home page Giter Site logo

Comments (11)

1171736840 avatar 1171736840 commented on June 6, 2024

请提供你的代码

from x-file-storage.

Gerrit1999 avatar Gerrit1999 commented on June 6, 2024

service:

public FileDetail upload(@NonNull MultipartFile file, boolean generateThumbnail) {
    String contentType = file.getContentType();
    FileInfo info = storageService.of(file)
            // 缩略图配置
            .thumbnail(generateThumbnail &&
                    contentType != null &&
                    contentType.matches("^image/(jpeg|png|gif)$"))
            // 相对路径设置为日期
            .setPath(FastDateFormat.getInstance("yyyy/MM/dd/").format(new Date()))
            .upload();
    return BeanUtil.copyProperties(info, FileDetail.class);
}

配置文件:

spring:
  # 文件存储配置
  file-storage:
    default-platform: amazon-s3-1 # 默认使用的存储平台
    thumbnail-suffix: .min.png # 缩略图后缀
    # 对应平台的配置
    amazon-s3:
      - platform: amazon-s3-1 # 存储平台标识
        enable-storage: true  # 启用存储
        access-key: 
        secret-key: 
        end-point: http://localhost:7480
        bucket-name: demo
        domain: ${spring.file-storage.amazon-s3[0].endpoint}/${spring.file-storage.amazon-s3[0].bucket-name}/ # 访问域名, 注意"/"结尾

from x-file-storage.

1171736840 avatar 1171736840 commented on June 6, 2024

好的,再提供一下依赖版本以及上传的文件大小,你自己也可以尝试换个依赖版本试一下

from x-file-storage.

1171736840 avatar 1171736840 commented on June 6, 2024

这个出现的原因是上传失败,s3的SDK有重试的行为,重试时会重新读取流,就发生了这种情况

from x-file-storage.

1171736840 avatar 1171736840 commented on June 6, 2024

还有你连接的是s3的服务器,还是其它?

from x-file-storage.

Gerrit1999 avatar Gerrit1999 commented on June 6, 2024

好的,再提供一下依赖版本以及上传的文件大小,你自己也可以尝试换个依赖版本试一下

我用的1.0.1, 升级到1.0.3后也有这个问题
文件大小不到1mb, 在几秒内多次上传会出现这个问题

from x-file-storage.

Gerrit1999 avatar Gerrit1999 commented on June 6, 2024

还有你连接的是s3的服务器,还是其它?

用的是自己部署的ceph
我试了用ZFile上传没问题

from x-file-storage.

Gerrit1999 avatar Gerrit1999 commented on June 6, 2024

这个出现的原因是上传失败,s3的SDK有重试的行为,重试时会重新读取流,就发生了这种情况

应该是这个原因, 我试着改了下MultipartFileWrapper.getInputStream中创建流的缓冲区大小, 就没有再出现了:

public InputStream getInputStream() throws IOException {
    if (this.inputStream == null) {
        this.inputStream = new BufferedInputStream(this.file.getInputStream(), RequestClientOptions.DEFAULT_STREAM_BUFFER_SIZE);
    }
    return this.inputStream;
}

from x-file-storage.

1171736840 avatar 1171736840 commented on June 6, 2024

好的,我这边也处理一下

from x-file-storage.

1171736840 avatar 1171736840 commented on June 6, 2024

这个问题已修复,已提交到dev分支,等下个版本一起发布,你可以先拉取dev分支验证一下

from x-file-storage.

Gerrit1999 avatar Gerrit1999 commented on June 6, 2024

验证成功,期待新版本发布

from x-file-storage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.