How do I block uploads that lack “DateTimeOriginal” exif data with Fine Uploader?

我是研究僧i 提交于 2019-12-13 21:50:38

问题


I have an app where having the DateTimeOriginal time stamp on photos are absolutely necessary. Is there a way for me to stop uploading and display a message using Fine Uploader?


回答1:


I've never heard of the "taken-at" tag, and I don't believe this is a standard field. The rest of this answer assumes you really do want to focus on this tag, but even if you don't you can make a simple change in the source code below to focus on another EXIF tag instead.

One approach is to check each file in an onSubmit callback handler and simply reject the file is it does not contain a "taken-at" field. The following example utilizes the exif-js library to parse an image file's EXIF data:

var uploader = new qq.FineUploader({
  callbacks: {
     onSubmit: function(id) {
       var blob = this.getFile(id)
       return new Promise(function(resolve, reject) {
         EXIF.getData(blob, function() {
           var takenAt = EXIF.getTag(this, 'taken-at')
           if (takenAt) {
             resolve()
           }
           else {
             reject()
           }
         })
       })
     } 
   }
})


来源:https://stackoverflow.com/questions/41411117/how-do-i-block-uploads-that-lack-datetimeoriginal-exif-data-with-fine-uploader

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!