Dropzonejs - 在上传之前重命名文件

Adr*_*lls 3 jquery amazon-s3 dropzone.js

我有dropzone设置并使用我的AWS S3帐户.但是,我希望能够在将文件发送到S3之前重命名该文件(例如,附加时间戳),以便上载与现有文件同名的文件不会被覆盖.我试图在发送事件中捕获这个并在此时更新文件名但没有成功:

this.on("sending", function(file) {
  file.name = 'my-new-prefix-' + file.name;
});
Run Code Online (Sandbox Code Playgroud)

我出错的任何想法或为什么这不起作用?

此前也提到过 - https://github.com/enyo/dropzone/issues/345

Pie*_*ucz 5

我目前使用FromData() - Dropzone.js,它允许您发送自定义数据.

// with options.params = true;

this.on("sending", function(file) {
  formData.append("custom", "my-new-prefix-" + file.name);
});
Run Code Online (Sandbox Code Playgroud)

我知道这不是你的问题,它只是一个临时的解决方案而不修改源代码

您还可以直接在选项中传递对象:

el.dropzone({
  params: {
    data: "data"
  }
});
Run Code Online (Sandbox Code Playgroud)