meteor - cfs :s3 how to get url after upload?

标签 meteor amazon-s3

我无法理解 cfs:s3 是如何工作的。 在我的客户端上

images = new FS.Store.S3('images')

@Images = new FS.Collection "allImages",
  stores: [images]
  filter:
    allow:
      contentTypes: ['image/*']

在与 key 相同的服务器上。 并更改事件

"change .file-image": (e) ->
    console.log("changed!")
    FS.Utility.eachFile e, (file) ->
      Images.insert file, (err,fileObj) ->
        console.log 'fileObj',fileObj

毕竟它不明白该怎么做,如何上传和获取网址?

最佳答案

当您创建 cfs 对象时,您通常希望保留其 _id,例如:

let imageId = Images.insert file

Images.insert file, (err,fileObj) ->
    let imageId = fileObj._id

cfs 可能需要一段时间才能完成文件加载,但在上传完成之前该 URL 不可用。

let url = fileObj.isUploaded() ? fileObj.url() : null

在火焰中可能看起来像:

{{#if this.isUploaded}}
  <a href="{{this.url}}">download the file</a>
{{else}}
  {{> progress}}
{{/if}}

最后,由于 cfs 项目受到的关注越来越少,您可能希望切换到 edgee:slingshot

关于meteor - cfs :s3 how to get url after upload?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30563428/

相关文章:

javascript - Meteor/Iron Router 外部重定向

docker - meteor-up (mup) 新的 docker 镜像

javascript - Meteor 的简单模式,不返回数字的方法

amazon-s3 - 带Lambda的Amazon Step Function从Kinesis触发

javascript - AWS S3 multipart/uploadPart 浏览器 JS SDK 静默失败

java - 为什么 AmazonS3Client 不使用我设置的代理?

meteor - 为什么 If/Else 空格键标签不起作用?

amazon-s3 - 如何使用 meteor 将图像从 FileReader 上传到 Amazon s3

c# - Amazon s3 API上传文件时如何设置权限

amazon-web-services - 如何解决 AWS 上的最终一致性问题