Meteor cfs:s3上传后如何获取url?
我无法理解cfs:s3是如何工作的。 我有一个客户Meteor cfs:s3上传后如何获取url?,meteor,amazon-s3,Meteor,Amazon S3,我无法理解cfs:s3是如何工作的。 我有一个客户 images = new FS.Store.S3('images') @Images = new FS.Collection "allImages", stores: [images] filter: allow: contentTypes: ['image/*'] 在具有相同密钥的服务器上。 和变化事件 "change .file-image": (e) -> console.log("chang
images = new FS.Store.S3('images')
@Images = new FS.Collection "allImages",
stores: [images]
filter:
allow:
contentTypes: ['image/*']
在具有相同密钥的服务器上。
和变化事件
"change .file-image": (e) ->
console.log("changed!")
FS.Utility.eachFile e, (file) ->
Images.insert file, (err,fileObj) ->
console.log 'fileObj',fileObj
毕竟,它不知道该做什么,如何上传和获取url?当您创建cfs对象时,您通常希望保留其
\u id
,例如:
let imageId = Images.insert file
或
cfs可能需要一段时间才能完成加载文件,但是,在上传完成之前,url不可用
let url = fileObj.isUploaded() ? fileObj.url() : null
在火焰中可能看起来像:
{{#if this.isUploaded}}
<a href="{{this.url}}">download the file</a>
{{else}}
{{> progress}}
{{/if}}
{{#如果这个.isupload}
{{else}
{{>进度}
{{/if}
最后,由于cfs项目越来越不受关注,您可能希望切换到JavaScript中的,我设置了一个间隔,每秒钟检查一次(当然您可以自己设置时间段),fileObj.isupload()为true。如果是这种情况,则使用fileObj.url()获取url。也许这有帮助:如果你在Meteor 1.3上,我建议直接使用Amazon的SDK,而不是CollectionFS。
{{#if this.isUploaded}}
<a href="{{this.url}}">download the file</a>
{{else}}
{{> progress}}
{{/if}}