如何检索通过CollectionFS:S3上传到Amazon S3的图像 [英] How do I retrieve an image uploaded to Amazon S3 via CollectionFS:S3

查看:86
本文介绍了如何检索通过CollectionFS:S3上传到Amazon S3的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Meteor项目中,我正在使用 CollectionFS:S3 将图像保存到S3中的存储桶.我看不到如何将它们重新加载到项目中.

In a Meteor project I am using CollectionFS:S3 to save images to a bucket in S3. I'm not able to see how to load them back into the project.

我试图使用FSFile.url()方法,如下面的代码所示,但它正在返回: /cfs/files/images/e6jQ4Txgvb37GisEQ/imagename.jpg?token=XXX

I have tried to use the FSFile.url() method as show in the code below but it's returning: /cfs/files/images/e6jQ4Txgvb37GisEQ/imagename.jpg?token=XXX

我期待的是Amazon S3网址,如s3-eu-west-1.amazonaws.com/mybucket/myfolder/imagename.jpg

I was expecting an Amazon S3 url as in s3-eu-west-1.amazonaws.com/mybucket/myfolder/imagename.jpg

view.html:

view.html:

  {{#each images}}
    URL: {{this.url}}
    <img src="{{this.url}}" alt="thumbnail">
  {{/each}}

view.js

 images: function () {
  return images.find();
 }

我在CollectionFS github页面上看到的所有示例都使用url方法,因此看不到为什么我无法访问图像.

All examples I can see on the CollectionFS github page use the url method so can't see why I'm not able to access the images.

推荐答案

这实际上是正确的.您从服务器获取了一个URL,服务器将该URL重定向到S3上的正确文件.

That's actually correct. You're getting a url from the server which the server redirects to the correct file on S3.

换句话说,从概念上讲,服务器充当S3的代理,该服务器提供对S3上文件的临时访问(因此在末尾添加了令牌).

In other words conceptually the server serves as a proxy to S3 that serves temporary access to files on S3 (hence the token at the end).

如果检查图像收集服务器端(流星外壳),则会看到它指向S3集合中的相对路径.

If you inspect the image collection server-side (meteor shell) you'll see that it's pointing to the relative path within your S3 collection.

如果未正确显示图像,则可能有其他情况发生,但是应该使用cfs提供的网址.

If it's not displaying the image correctly there's something else going on, but it should with the url provided by cfs.

这篇关于如何检索通过CollectionFS:S3上传到Amazon S3的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆