Giter VIP home page Giter VIP logo

veliovgroup / meteor-files Goto Github PK

View Code? Open in Web Editor NEW
1.1K 37.0 165.0 10.46 MB

🚀 Upload files via DDP or HTTP to ☄️ Meteor server FS, AWS, GridFS, DropBox or Google Drive. Fast, secure and robust.

Home Page: https://packosphere.com/ostrio/files

License: BSD 3-Clause "New" or "Revised" License

JavaScript 100.00%
meteor meteor-package meteor-files gridfs google-storage aws-s3 dropbox upload file-upload websockets

meteor-files's Issues

Can't get logged user in 'protected' function

Hi,

I'm trying to add some security when downloading files but I can't get the user info inside the 'protected' function. My configuration looks like this:

Documents = new Meteor.Files({
  storagePath: "D:/temp",
  collectionName: 'documents',
  downloadRoute: '/doc',
  allowClientCode: true,
  chunkSize: 256*128,
  protected: (fileObj) => {
    console.log(fileObj);
    return true;
  }
});

The file is downloaded and I can get the info of the fileObj but I tried this.userId (undefined), this.user() -gives an TypeError.. has no method 'user'.

What am I doing wrong?

Upload pause not working

Hello,

I get the following client error when I try to pause a file upload:

TypeError: Cannot read property 'get' of undefined at Meteor.Files.Files.insert.Meteor.isClient.result.toggle (files.coffee:791)

files.coffee:791

...
          toggle: () ->
            if @onPause.get() then @continue() else @pause() 
...

This is how I call the funcion:

       this.insert;
       this.addFile = (files) => {
        ...

         this.insert = Documents.insert({
          ...
         });
      }

      this.togglePause = () => {
        if (this.insert !== undefined) {
          this.insert.toggle.call();
        }
      }

this.insert.onPause is returning false. Why @onpause is undefined?

v1.4.2 uploading large files doesn't work anymore ?

Hi,

Firstly thanks for this new version. We can now play videos on all browsers. Good work and thank you for your reactivity !

Unfortunately with this new version when i try to upload a small file, it works perfectly but if i try with a larger file (in my case more than 300Mo but I will try other size to test) the upload process freeze, no chunk is sent to the server.
There was no problem with the previous version.

I can't test it with your live demo because we can't upload a file larger than 128Mo.

add package breaks app

i think something conflict with files package

W20150916-23:31:03.689(8)? (STDERR)
W20150916-23:31:03.690(8)? (STDERR) /Users/monsterstep/.meteor/packages/meteor-tool/.1.1.4.16s0drq++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150916-23:31:03.690(8)? (STDERR)                         throw(ex);
W20150916-23:31:03.690(8)? (STDERR)                               ^
W20150916-23:31:03.690(8)? (STDERR) TypeError: Object function (){                                                                                         // 253
W20150916-23:31:03.691(8)? (STDERR)         if( Object.prototype.toString.call(this) !== '[object Object]' &&                                      // 254
W20150916-23:31:03.691(8)? (STDERR)             Object.prototype.toString.call(this) !== '[object Array]'){                                        // 255
W20150916-23:31:03.691(8)? (STDERR)             return undefined;                                                                                  // 256
W20150916-23:31:03.691(8)? (STDERR)         }                                                                                                      // 257
W20150916-23:31:03.691(8)? (STDERR)         return this[Math.floor(Math.random() * this.length)];                                                  // 258
W20150916-23:31:03.691(8)? (STDERR)     } has no method 'arrayElement'
W20150916-23:31:03.691(8)? (STDERR)     at [object Object].self.phoneFormats (/Volumes/Data/dev/nexushubs/lawflow/lawflow-system/.meteor/local/isopacks/npm-container/npm/node_modules/faker/lib/phone_number.js:16:25)
W20150916-23:31:03.691(8)? (STDERR)     at [object Object].self.phoneNumber (/Volumes/Data/dev/nexushubs/lawflow/lawflow-system/.meteor/local/isopacks/npm-container/npm/node_modules/faker/lib/phone_number.js:5:38)
W20150916-23:31:03.691(8)? (STDERR)     at server/fixtures.coffee:25:25
W20150916-23:31:03.691(8)? (STDERR)     at server/fixtures.coffee:5:1
W20150916-23:31:03.691(8)? (STDERR)     at /Volumes/Data/dev/nexushubs/lawflow/lawflow-system/.meteor/local/build/programs/server/boot.js:222:10
W20150916-23:31:03.691(8)? (STDERR)     at Array.forEach (native)
W20150916-23:31:03.692(8)? (STDERR)     at Function._.each._.forEach (/Users/monsterstep/.meteor/packages/meteor-tool/.1.1.4.16s0drq++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150916-23:31:03.692(8)? (STDERR)     at /Volumes/Data/dev/nexushubs/lawflow/lawflow-system/.meteor/local/build/programs/server/boot.js:117:5
=> Exited with code: 8
W20150916-23:31:09.259(8)? (STDERR)
W20150916-23:31:09.259(8)? (STDERR) /Users/monsterstep/.meteor/packages/meteor-tool/.1.1.4.16s0drq++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150916-23:31:09.259(8)? (STDERR)                         throw(ex);
W20150916-23:31:09.259(8)? (STDERR)                               ^
W20150916-23:31:09.273(8)? (STDERR) TypeError: Object function (){                                                                                         // 253
W20150916-23:31:09.273(8)? (STDERR)         if( Object.prototype.toString.call(this) !== '[object Object]' &&                                      // 254
W20150916-23:31:09.273(8)? (STDERR)             Object.prototype.toString.call(this) !== '[object Array]'){                                        // 255
W20150916-23:31:09.273(8)? (STDERR)             return undefined;                                                                                  // 256
W20150916-23:31:09.274(8)? (STDERR)         }                                                                                                      // 257
W20150916-23:31:09.274(8)? (STDERR)         return this[Math.floor(Math.random() * this.length)];                                                  // 258
W20150916-23:31:09.274(8)? (STDERR)     } has no method 'arrayElement'
W20150916-23:31:09.274(8)? (STDERR)     at [object Object].self.phoneFormats (/Volumes/Data/dev/nexushubs/lawflow/lawflow-system/.meteor/local/isopacks/npm-container/npm/node_modules/faker/lib/phone_number.js:16:25)
W20150916-23:31:09.274(8)? (STDERR)     at [object Object].self.phoneNumber (/Volumes/Data/dev/nexushubs/lawflow/lawflow-system/.meteor/local/isopacks/npm-container/npm/node_modules/faker/lib/phone_number.js:5:38)
W20150916-23:31:09.274(8)? (STDERR)     at server/fixtures.coffee:25:25
W20150916-23:31:09.275(8)? (STDERR)     at server/fixtures.coffee:5:1
W20150916-23:31:09.275(8)? (STDERR)     at /Volumes/Data/dev/nexushubs/lawflow/lawflow-system/.meteor/local/build/programs/server/boot.js:222:10
W20150916-23:31:09.275(8)? (STDERR)     at Array.forEach (native)
W20150916-23:31:09.275(8)? (STDERR)     at Function._.each._.forEach (/Users/monsterstep/.meteor/packages/meteor-tool/.1.1.4.16s0drq++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150916-23:31:09.275(8)? (STDERR)     at /Volumes/Data/dev/nexushubs/lawflow/lawflow-system/.meteor/local/build/programs/server/boot.js:117:5
=> Exited with code: 8
W20150916-23:31:14.633(8)? (STDERR)
W20150916-23:31:14.633(8)? (STDERR) /Users/monsterstep/.meteor/packages/meteor-tool/.1.1.4.16s0drq++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150916-23:31:14.633(8)? (STDERR)                         throw(ex);
W20150916-23:31:14.634(8)? (STDERR)                               ^
W20150916-23:31:14.648(8)? (STDERR) TypeError: Object function (){                                                                                         // 253
W20150916-23:31:14.648(8)? (STDERR)         if( Object.prototype.toString.call(this) !== '[object Object]' &&                                      // 254
W20150916-23:31:14.648(8)? (STDERR)             Object.prototype.toString.call(this) !== '[object Array]'){                                        // 255
W20150916-23:31:14.648(8)? (STDERR)             return undefined;                                                                                  // 256
W20150916-23:31:14.648(8)? (STDERR)         }                                                                                                      // 257
W20150916-23:31:14.649(8)? (STDERR)         return this[Math.floor(Math.random() * this.length)];                                                  // 258
W20150916-23:31:14.649(8)? (STDERR)     } has no method 'arrayElement'
W20150916-23:31:14.649(8)? (STDERR)     at [object Object].self.phoneFormats (/Volumes/Data/dev/nexushubs/lawflow/lawflow-system/.meteor/local/isopacks/npm-container/npm/node_modules/faker/lib/phone_number.js:16:25)
W20150916-23:31:14.649(8)? (STDERR)     at [object Object].self.phoneNumber (/Volumes/Data/dev/nexushubs/lawflow/lawflow-system/.meteor/local/isopacks/npm-container/npm/node_modules/faker/lib/phone_number.js:5:38)
W20150916-23:31:14.649(8)? (STDERR)     at server/fixtures.coffee:25:25
W20150916-23:31:14.649(8)? (STDERR)     at server/fixtures.coffee:5:1
W20150916-23:31:14.649(8)? (STDERR)     at /Volumes/Data/dev/nexushubs/lawflow/lawflow-system/.meteor/local/build/programs/server/boot.js:222:10
W20150916-23:31:14.649(8)? (STDERR)     at Array.forEach (native)
W20150916-23:31:14.649(8)? (STDERR)     at Function._.each._.forEach (/Users/monsterstep/.meteor/packages/meteor-tool/.1.1.4.16s0drq++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150916-23:31:14.649(8)? (STDERR)     at /Volumes/Data/dev/nexushubs/lawflow/lawflow-system/.meteor/local/build/programs/server/boot.js:117:5

ReferenceError: check is not defined with Meteor 1.1.0.2

I can't start meteor because of the following error:

ReferenceError: check is not defined
    at new Files (packages/ostrio:files/files.coffee:147:5)
    at Files.allow.insert (packages/app-filestore/lib/files.js:1:1)
    at /home/jokke/code/projects/tagfs/.meteor/local/build/programs/server/packages/app-filestore.js:28:4
    at /home/jokke/code/projects/tagfs/.meteor/local/build/programs/server/packages/app-filestore.js:92:3
    at /home/jokke/code/projects/tagfs/.meteor/local/build/programs/server/boot.js:222:10
    at Array.forEach (native)
    at Function._.each._.forEach (/home/jokke/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
    at /home/jokke/code/projects/tagfs/.meteor/local/build/programs/server/boot.js:117:5

ROOT_URL and File Not Found :(

Hi,

I'm afraid I don't understand using ROOT_URL in this package. Please help, what is the correct way.

Example:
When I upload images in my dev system locally with ordinary:
meteor --port 3000
everything works as expected.

But when I want to change path with ROOT_URL to access same system for testing external access with:
ROOT_URL=http://palpinter.dlinkddns.com:3000 meteor --port 3000
I receive 'File Not Found :(' error message for all uploaded images.

And if change the port only:
meteor --port 3030
the result is the same, ''File Not Found :(' for all uploaded images.

How can I change ROOT_URL to access my uploaded images?

Thx
Pal

is it possible to update the metadata?

I am trying to update the metadata of an existing Images collection like this:
Images.collection.update(this._id, {$set: {'meta.big': !this.meta.big}});
'big' is a boolean.
but i get update failed: Access denied

my fault or impossible?

Add upload state property

It would be useful to support the state of the upload in the object returned from files.insert()

Perhaps name it state with its only values being:

  • active
  • paused
  • aborted
  • completed

That would be very helpful in styling the progress bar relative to the upload state, so users could easily see the status of their upload.

Images disappear after server restart

I am saving all my images in directory: storagePath: 'assets/uploads/avatars/' and after restart server directory with files disappear. All data still exist in collection but files are gone. Maybe I have to store images in another place?

Example of user permission checking function (protected attribute)

Great library! I'm almost done with my app thanks to you, but I'm trying to define a custom protected function for advanced permission checking and user() and userId remain undefined.

Maybe it's a bug. To be sure, could you add to the demo an example of a custom protected function using all parameters?

Thanks again!

cant show inserted image

hi,

I use thus code

    {{#if currentFile}}
        Uploading <b>{{currentFile.file.name}}</b>:
        <span id="progress">{{progress}}%</span>
        <img src="{{fileURL imageFile}}" alt="{{imageFile.name}}"/>
    {{else}}
        <input id="fileInput" type="file"/>
    {{/if}}
    <hr>

and that in template helper

   imageFile: function () {
        return InterestIcons.collection.findOne({});
    }

and cant see the uploaded image

Best regards

Large file upload performance?

Hi Meteor-Files team,

Any solution for upload a file ~10GB via DDP without RAM dependence?
I'm building a storage service and allow user upload file(s) in any size.

can find uploaded images in folder

Hi,
I'm using version 1.2.1 on osx 10.11(el capitan) and I cant find my uploaded images on FS. debug says
Meteor.Files Debugger: The file tennis-icon.png (binary) was saved to assets/app/uploads/uploadedFiles/knRbZlNgtDVFEuFrp.png but this kind of path doest even exist
Please help me :) thanks
Best Regards

Small working sample

Hi,

I could not find an email address or other contact information so I am opening an issue to really ask a question. Is there a small working sample of Meteor-Files anywhere? The readme is overwhelming and in coffee so it's not great for new Meteor developers that may not know coffee. It would really help if there was just a small real working example of uploading a small file to FS somewhere.

Client sets file location once, Server can access at will

My project is reading clients game log files and outputting results. I have client set location for a text log file for a game they play when they sign up. Currently only the upload occurs when client calls the upload. I want it to be so that once file location is defined/set then both client and server can access file passively without client having to explicitly call upload. So once client is logged in I would have access to file as a streaming read/write that can be open/called at any time. Is this currently possible and I am failing on way to implement or would this be possible as enhancement?
Thank you for reviewing.

TypeError: Cannot read property 'indexOf' of undefined

Hi,

when I tried upload with this:

      Images.insert
        file: file
        onUploaded: (error, fileObj) ->
          if error
            alert 'Error during upload: ' + error
          else
            alert 'File "' + fileObj.name + '" successfully uploaded'
          return
        streams: 'dynamic'
        chunkSize: 'dynamic'

TypeError: Cannot read property 'indexOf' of undefined
    at FilesCollection.getExt (files.coffee:550)
    at new UploadInstance (files.coffee:907)
    at FilesCollection.insert (files.coffee:851)
    at ViewModel.Template.SignUp.viewmodel.uploadPicture (sign-up.coffee:55)

Of course the 'file' is exist. Its name: 'img.png'

Thx
Pal

Feature request

Little feature request. I think it would be helpful to have the ability to prevent auto upload. So we can render custom UI controllers for the upload and then manually call continue()

Duplicate headers received from server

In Chrome Browser:
Duplicate headers received from server
ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION
Details:
The response from the server contained duplicate headers. This problem is generally the result of a misconfigured website or proxy. Only the website or proxy administrator can fix this issue.

pass meta to onBeforeUpload

Sometimes I need to do validations based on user input, e.g. the directory name which the uploaded file should be referenced to. In those cases I need to check permissions on onBeforeUpload, but since the meta obj is not available there is no way to determine the permission.

How would this be solved with this lib? Any chance to add meta as additional arg to onBeforeUpload call?

Thanks in advance.

Support for Angular?

I would like to use Meteor-Files with AngularJS (files list, progress bar, message, etc.)
Can your team support or planning for it?

My bad English :)
Thanks.

UPDATE:
I've found settings obj in Insert API.

".remove" sets the storagePath to null

If i remove a record with: Images.collection.remove({_id:id});

Everything works as expected. (The record is removed from the "Images" Collection.)
If a insert new files after that, they are added to the Collection and FS at 'local\build\programs\server\assets\app\uploads'
So, no problems here.

If i want to remove the record AND the file from the FS with: Images.remove({_id: id}); (same code expect this line)

Also, everything works as expected. (record and file from FS gets removed, no errors)

BUT, ALL FILES that i insert after that, are uploaded in an "undefined" folder at "local\build\programs\server\undefined" in opposite to the 'local\build\programs\server\assets\app\uploads' folder before.

If you get the output of the file records in Images.find({}).fetch(); the storagePath is null ('assets/app/uploads' before the remove) and the "path" is something like "undefined/6PTvaQYHdHJe9n6bj.jpg".

I have this problem on windows and on the ubuntu server that i host.

How can I get the height and width of uploaded images?

This code prints the image's width and height only after a timeout.

                    onUploaded: function (error, fileRef) {

                        var img = new Image;
                        img.src = Blaze._globalHelpers['fileURL'](fileRef);
                        setTimeout(function () {
                            console.log("5 sec delay:", img.height, " x ", img.width);
                        }, 5000);
                        console.log("First try: ", img.height, " x ", img.width);

Is there a way to get this data without using a timeout?

What template language do you use?

Hi,

can you tell me what template language / system you use in the examples in the README? Looks a lot like HAML and I'd love to try that out ;)

Thanks in advance

How to add additional fields to collection.doc and not to collection.doc.meta

I need to add additional data to the created document. Currently this is only possible trough config.meta. My collection is created like:

const FooFiles = new FilesCollection({
  collectionName: 'FooFiles',
});

const MetaSchema = new SimpleSchema({
  fooId: {
    type: String,
  },
});

const FooFilesSchema = new SimpleSchema({
  ...FooFiles.schema,
  meta: {
    type: MetaSchema,
  },
});

FooFiles.collection.attachSchema(FooFilesSchema);

note: imho this is the proper way to attach schema to a collection, the current documentation does not follow collection2/simple schema guidelines

What I really need is to be in full control of the document because I need to set the Index on fooId e.g.

Update: Of course indexes can be applied to nested fields which solves this scenario

  fooId: {
    type: String,
    index: true,
  },

I love this lib, it has everything I need and it works very well. This is the only feature I miss a lot, would be quiet happy about a clean and straightforward solution.
Maybe a second object like config.doc could help here. Later on this could just be merged with existing data like {...config.doc, ...currentInsertedObj}, validation should be done trough SimpleSchema.

Service Unavailable when using ?play=true in the demo

Hi,
thank you for this great plugin!

The only thing that doesn't work for me is the ?play=true streaming (with an mp3 file). The download option works but the play option returns "Service Unavailable" (Screenshot of the demo can be found attached).

Could you please give me a hint why this is happening? Thanks!
serviceunavailable_503

No compatible binary build found for this package

Hi,

I wanted to update my packages today and it seems that the Meteor-Files one (ostrio:files) is somehow broken currently (at least for me).
nocompatiblebinary

There might have occured an error in one of the later steps of publishing the build.

No Preview for files

Hi, I don't get any file prelisten or view here:

http://_.meteor.com/gt2uRGekimkrjRWhb

?

Playing video with "?play=true"

Thank you for this good meteor package.

When I upload a video file and I try to play it on Google Chrome (Desktop), it works perfectly but with an other browser, for example Mozilla Firefox, you can just read the first few seconds an it stops. And with Safari it just does not work.

You can experiment that with the Meteor-Files live demo. Upload the demo video file of the VideoJS website (playing well on all the browser mobile/desktop).

Thx.

Exception from sub Images

Hi

I got this kind of exception

Meteor.Files Debugger: [find(undefined)]
I20160409-16:15:55.655(2)? Exception from sub Images id GngR84PRRRtf9ZjhC Error: Match error: Failed Match.OneOf, Match.Maybe or Match.Optional validation
I20160409-16:15:55.655(2)?     at check (packages/check.js:138:15)
I20160409-16:15:55.655(2)?     at Files.Meteor.Files.Files.find (packages/ostrio_files/files.coffee:695:5)
I20160409-16:15:55.656(2)?     at Subscription._handler (server/init.js:10:26)
I20160409-16:15:55.656(2)?     at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)
I20160409-16:15:55.656(2)?     at Subscription._runHandler (packages/ddp-server/livedata_server.js:1026:17)
I20160409-16:15:55.656(2)?     at Session._startSubscription (packages/ddp-server/livedata_server.js:845:9)
I20160409-16:15:55.656(2)?     at Session.sub (packages/ddp-server/livedata_server.js:617:12)
I20160409-16:15:55.656(2)?     at packages/ddp-server/livedata_server.js:551:43
I20160409-16:15:55.657(2)? Sanitized and reported to the client as: Match failed [400]

thanks for help
Best Regards
Michal

How to display files on meteor 1.3 + reactjs

Hi,

I can use fileURL template helper on blaze.
If i use meteor 1.3 + reactjs, how can I display files?

I tried like below
src=${image._downloadRoute}/${image._id}.${image.extension}

Thank you

Error removing image with versions

Im having an issue when trying to remove an image that has version, im getting the following error

Error invoking Method 'MeteorFileUnlink9b7534345192d71efbfeb0a333fe42deb50e466382219d2bf904a0220380f3ad': Internal server error [500]

When removing files without any version it wont happen.

React Native upload image/video to meteor server

Hello there, i try to upload image in from react-native to meteor using base64 encode for image and its working, but i would like to know if you have idea how to upload from external like react-native to Meteor Server with file path. i know that in heruko they use ephemeral filesystem, so i can use my own server to upload video/audio? any codes in react-native to meteor? i use DDP Client

Thanks

How to use subversions

Hi,

I tried as below

const Images = new FilesCollection({
  ......
  onAfterUpload: function( fileRef ) {
    const cropName = fileRef.path + "__thumbnail__.jpg"
    Imagemagick.crop({
      srcPath: fileRef.path,
      dstPath: cropName,
      width: 200,
      height: 200,
      quality: 0.8,
      gravity: "Center"
    })
    const upd = {
      $set: {
        "versions.thumbnail" : {
          path: cropName,
          type: "image/jpeg",
          extension: "jpg"
        } 
      }
    }
    return Images.update( fileRef._id, upd )
  }
  ......
})

I could see the thumnail file generated on the same directory with original one.

on client side code

this.images().map(( image ) => {
  return (
    <li key={image._id}>  
      <img src={Images.link(image, "thumbnail")} />
    </li>
  )
})

'scr' attribute looks like "......id/thumbnail/id.jpg" but the image shown up is not a 200x200 thumbnail. It is just original one.

Example for AWS S3 Integration

I have seen thi is in the Roadmap, and I just want to give it a 👍 since it would be a very common use case (even more than dropbox I think).
Good work on this package :)

Mach error on upload

thanks for the fast fix of my last issue! Now I'm getting an error when uploading a file. Not sure if this is a bug or some misconfiguration on my side.

Exception while invoking method 'MeteorFileWrite27cbfcbe172a3d9bf03834c002d75f0926d0fa16f28594a4ac80e587325df05f' Error: Match error: Failed Match.OneOf or Match.Optional validation
    at checkSubtree (packages/check/match.js:244:1)
    at check (packages/check/match.js:32:1)
    at [object Object].Files._methods.(anonymous function) (packages/ostrio:files/files.coffee:266:9)
    at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1617:1)
    at packages/ddp/livedata_server.js:648:1
    at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
    at packages/ddp/livedata_server.js:647:1
    at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
    at [object Object]._.extend.protocol_handlers.method (packages/ddp/livedata_server.js:646:1)
    at packages/ddp/livedata_server.js:546:1
Sanitized and reported to the client as: Match failed [400]

How to get a file names?

Hey. Anybody can tell, how to get the file name and simply insert it into the src? I read the documentation and I'm probably doing something wrong. Because in the collection, I see a lot of things, but I don't see the original file name.

PhotosCollection.load(photoLink, {
      fileName: `${id}.png`,
});

but it did not help, files are still named differently.

When I tried to make ImagesCollection.findOne ({_ id: id}) link (); I got links to files without the extension. The path to the file at the same time look strange. Something like
http://localhost:3000/public/photos/photos/Gd99qerb3e4y6Ee3m/original/Gd99qerb3e4y6Ee3m

My collection settings

PhotosCollection = new FilesCollection({
    storagePath: process.env.PWD + '/public/photos',
    downloadRoute: '/public/photos',
    collectionName: 'photos',
    allowClientCode: false,
    cacheControl: 'public, max-age=31536000',
    onBeforeUpload(file) {
        if (file.size <= 20971520 && /png|jpg|jpeg/i.test(file.ext)) {
            return true;
            } else {
            return 'Please upload image, with size equal or less than 20MB';
        }
    },
    downloadCallback(fileObj) {
        if (this.params.query.download == 'true') {
            // Increment downloads counter
            PhotosCollection.update(fileObj._id, {$inc: {'meta.downloads': 1}});
        }
        return true;
    }
});

I just want to get an array of names of files and display them on the client, it is possible even without a path. I write them by myself ;)

Get FilesCollection instance by name

I was wondering if this was possible. Right now I'm working to get this package working in full compatibility with AutoForm and I only need to get instantiated objects of FilesCollection by their name. I can get the mongo collection instance with a package from dburles, but when I trigger the remove on the mongo collection instance, the files don't get deleted. I need the remove method from FilesCollection.

Sure an snippet of what I want to do will help:

// FilesCollection instance
Files = new FilesCollection({
    collectionName: 'files', // name of the collection
    allowClientCode: true, // Allow or forbid remove files from Client
    onBeforeUpload: function (file) {
        if (file.size <= 10485760 ) {
          return true;
        } else {
          return 'El fichero excede el tamaño máximo permitido (10 MB)';
        }
    },
    permissions: 0777,
    storagePath: path,

});

// Current removal method:

Files.remove(...).

// What I want to do:

getFilesCollection({collectionName: 'files'}).remove(...)

Thank you for this awesome package!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.