Dropzonejs - 上传前重命名文件 [英] Dropzonejs - rename file before upload

查看:138
本文介绍了Dropzonejs - 上传前重命名文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有悬浮窗的设置和工作与我的AWS的S3帐户。不过,我希望能够重命名文件,然后再发送给S3(追加时间戳为例),使上传具有相同的名称与现有文件的文件不会被覆盖。我试图抓住这个在发送事件,并在这一点上,但没有成功升级的文件名:

I have dropzone set-up and working with my AWS S3 account. However I want to be able to rename the file before it is sent to S3 (append with timestamp for example) so that a file uploaded with the same name as an existing file will not get overwritten. I've tried to catch this at the sending event and to update the file name at this point but without success:

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

在任何地方我错了或这是为什么不工作思路?

Any ideas where I am going wrong or why this isn't working?

也已经提出了这个早些时候在 - https://github.com/enyo/dropzone/issues / 345

Also have raised this earlier at - https://github.com/enyo/dropzone/issues/345

推荐答案

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

I currently use FromData() - Dropzone.js which allows you to send custom data.

// with options.params = true;

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

我知道这不完全是你的问题,它只是一个临时的解决方案无需修改源$ C ​​$ C

I know this is not exactly what is your question, it is only a temporary solution without modifying the source code

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

You can also pass object directly in options:

el.dropzone({
  params: {
    data: "data"
  }
});

这篇关于Dropzonejs - 上传前重命名文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆