You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can add fileKeyMaker option on your FileSystem store, and set it to a function that returns the file key given a fileObj (FS.File instance). For now, you actually need to add some code to your function checking to see if a file key is already assigned. Hopefully we can handle that internally eventually.
Here's an example that would generate the same fileKey (which for the FileSystem store is the path) as default:
varimageStore=newFS.Store.FileSystem("images",{fileKeyMaker: function(fileObj){// Lookup the copyvarstore=fileObj&&fileObj._getInfo(name);// If the store and key is found return the keyif(store&&store.key)returnstore.key;// TO CUSTOMIZE, REPLACE CODE AFTER THIS POINTvarfilename=fileObj.name();varfilenameInStore=fileObj.name({store: name});// If no store key found we resolve / generate a keyreturnfileObj.collectionName+'-'+fileObj._id+'-'+(filenameInStore||filename);}});
The function receives only the fileObj so if you need the userId, you'll need to set it on every file when uploading in order to use it in your path.