如何阻止缺少"DateTimeOriginal"的上传用Fine Uploader提取exif数据? [英] How do I block uploads that lack "DateTimeOriginal" exif data with Fine Uploader?
问题描述
我有一个应用,其中绝对需要在照片上带有DateTimeOriginal时间戳.我可以使用Fine Uploader停止上传并显示消息吗?
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?
推荐答案
我从未听说过"taken-at"标签,而且我也不认为这是标准字段.该答案的其余部分假定您确实确实要关注此标签,但是即使您不愿意,您也可以在下面的源代码中进行简单的更改以改为关注另一个EXIF标签.
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.
一种方法是检查onSubmit
回调处理程序中的每个文件,并在文件中不包含"taken-at"字段的情况下直接拒绝该文件.以下示例利用 exif-js库来解析图像文件的EXIF数据:
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()
}
})
})
}
}
})
这篇关于如何阻止缺少"DateTimeOriginal"的上传用Fine Uploader提取exif数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!