简体   繁体   English

Dropzone会挂在大于1mb的文件上

[英]Dropzone hangs on files larger than 1mb

I'm using Dropzone.js in Meteor along with CollectionFS. 我在Meteor中使用Dropzone.js和CollectionFS。 I used it both as a package and standalone. 我既将其作为软件包使用,也将其独立使用。 Each time I did, everything works great except when I try to upload files over 1mb (It seems like that is the size limit at least) the progress bar just hangs and the "complete" callback never gets called. 每次我做的时候,一切都很好,除非我尝试上传超过1mb的文件(至少看起来是大小限制),进度条只是挂起,而“ complete”回调永远不会被调用。 I've tried a lot of the Dropzone options and nothing seems to resolve it. 我尝试了很多Dropzone选项,但似乎没有任何解决方案。 This is what I have: 这就是我所拥有的:

Javascript: Javascript:

Template.projectsNew.rendered = ->
   Meteor.dropzone = new Dropzone '#dropzone',
      url: '/'
      maxFilesize: 5
      maxFiles: 50
      maxThumbnailSize: 5
      init: ->
         @on 'complete', (file) ->
            Files.insert file, (error, fileObject) ->
               if error
                  console.log "Error: #{error}"
               else
                  uploadedFileIds = Session.get 'uploadedFileIds'
                  uploadedFileIds.push fileObject._id
                  Session.set 'uploadedFileIds', uploadedFileIds

HTML: HTML:

 fieldset
    legend Documents

    #dropzone.dropzone

Any help would be greatly appreciated. 任何帮助将不胜感激。

in case anyone else got stuck with this... I had the same problem, and got just absolutely stuck... finally worked it out after like 4+ hours of hitting walls. 万一其他人被卡住了……我也遇到了同样的问题,而且完全被卡住了……经过4个多小时的撞墙终于解决了。

so turns out dropzone loads and complete a post request, and i guess that's not how collectionFS or meteor handles it ... anyhoo I'm too beginner to understand all that. 所以原来是dropzone负载并完成了一个发布请求,我想那不是collectionFS或流星如何处理它的。。。。。。。。。。。。。。。。。

Long story short, the complete will never fire within dropzone , but you can catch the file upon 'accept', which is an option specification of dropzone, instead of an event. 长话短说, 完整的文件永远不会在dropzone中触发 ,但是您可以在“ accept”(这是dropzone的一个选项说明)而非事件的情况下捕获文件。

So I worked around it and make the collectionFS image store happens in the accept options, and just remove the icon afterward, which looks perfectly fine and works perfect as well! 因此,我解决了这个问题,并使collectionFS映像存储发生在accept选项中,然后仅删除了该图标,它看起来非常好,并且效果也很好!

<form action="#" class="dropzone" id="dropzone"></form>
var myDropzone = new Dropzone("#dropzone", {
  accept(file) {
    if (file.status == 'added') {

      var newFile = new FS.File(file);

      Images.insert(newFile, function (error, fileObj) {
        if (error) {
          ...
        }
          else {
            ...
          }

            // clear out dropzone
            myDropzone.removeFile(file);
          }
        });
      }
    }
});

If anyone need some extra help with this particular issue, please leave a comment or get in touch, I'll be happy to help further. 如果有人在此特定问题上需要其他帮助,请发表评论或联系我们,我们很乐意为您提供进一步的帮助。

You should consider the CollectionFS package . 您应该考虑CollectionFS软件包 One of its features is that it breaks files into pieces when uploading them to any number of storage options (gridFS, S3, etc...) 它的功能之一是在将文件上传到任意数量的存储选项(gridFS,S3等)时将文件分解成碎片

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在大于1MB的文件上,putObject()超时 - putObject() times out on files larger than ~1MB 如何使用 ajax 请求发送大于 1MB 的文件? - How to send files larger than 1MB with ajax request? 如何使用GitHub API和Octokit JavaScript将大于1mb的文件提交给GitHub - How to commit files larger than 1mb to GitHub using the GitHub API and Octokit JavaScript 无法在Dropzone中上传1mb以上的文件 - Can't upload files above 1mb in Dropzone 无法将大于 1MB 的文件从 JavaScript 上传到 Flask - Cannot upload files bigger than 1MB from JavaScript to Flask 如何使用 socket.io 和大于 1mb 的 nodejs 实现房间到房间的文件共享系统? - How to implement room to room file sharing system using socket.io and nodejs larger than 1mb? 无法使用 JS 加载大于 2MB 的 PDF 文件 - Can't load PDF files larger than 2MB with JS Payload Too Large - 当尝试上传大于 10MB 的文件时,在 dropzone.js 的控制台中说 - Payload Too Large - says in console from dropzone.js when try to upload file larger than 10MB 如何通过javascript验证上传的照片不大于1MB - how to validate the photo upload not greater than 1MB from javascript 如何在 nextJs 中将超过 1mb 的图像发送到后端 API - How to Send Images to Backend API more than 1mb in nextJs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM