Cfs: s3 how to get url after boot?

I can not understand how cfs: s3 works. On the client I have

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

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

The server is the same with keys. And change the event

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

But he can’t understand what to do, how to download and get the URL?

+4
source share
1 answer

When you create a cfs object, you usually want to save it _id, for example:

let imageId = Images.insert file

or

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

cfs may take some time to finish downloading the file, but the URL is not available until the download is complete.

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

In a flame that might look like this:

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

Finally, as the cfs project gets less attention, you can switch to edgee: slingshot

0
source

All Articles