Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor cfs:s3上传后如何获取url?_Meteor_Amazon S3 - Fatal编程技术网

Meteor cfs:s3上传后如何获取url?

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

我无法理解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("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}}