Lepozepo/S3

Calling S3.delete from server side

luckyvs1 opened this issue · 5 comments

Currently I'm trying to use the S3.delete function in the server side to delete an object after an x amount of time has passed. So after the appropriate time has passed using the Meteor.setTimeout the S3.delete function is called to delete the file from Amazon S3.

But I get the following error:
I20180121-15:01:39.901(-8)? Exception in setTimeout callback: TypeError: S3.delete is not a function I20180121-15:01:39.902(-8)? at app/server/document_manager/methods.js:24:11 I20180121-15:01:39.902(-8)? at [object Object]._.extend.withValue (packages/meteor.js:1122:17) I20180121-15:01:39.903(-8)? at packages/meteor.js:445:45 I20180121-15:01:39.903(-8)? at runWithEnvironment (packages/meteor.js:1176:24)

Is there a work around for calling S3.delete on the server side?

@Lepozepo, can you confirm if this is a valid solution I have tested it and it works, but want to know if there are any known issues, as I read the server side upload had some errors (re: your comments in #148).

In place of S3.delete, on the server side I would use the S3.knox.deleteFile, so the code is the following:

S3.knox.deleteFile(
  relative_path,
  function(err,response) {
    if(response) {
      console.log('Success, file has been deleted');
    } else {
      console.log('Unable to delete, please try again later');
    }
  }
);

I can't seem to markdown the code with my formatting intact, so apologies for the poorly formatted code.

@luckyvs1 no worries, that is definitely ok :D hope to enable server side uploads and functions again soon (for the very late christmas update lol)

Also @luckyvs1 you can use 3 ticks to format your code ^_^

is there any update on server side upload?

@harvinder34 I've been super disconnected from the Meteor community lately, I'll see if I can fit some time into upgrading some of these super old meteor packages next week with some of the new work I have on npm. If you really need server side uploads immediately, you might find it easier to use the aws-sdk package from AWS directly. Just do an npm i aws-sdk in your project and follow AWS's documentation for uploading server files.