Created
June 23, 2016 15:25
-
-
Save nicooprat/5ee6a22212faf049140ebf5a4df89380 to your computer and use it in GitHub Desktop.
S3 Delete File Lepozepo/S3#114
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future = Npm.require 'fibers/future' | |
Meteor.methods | |
_s3_delete: (path) -> | |
@unblock() | |
check path,String | |
future = new Future() | |
if S3.rules?.delete | |
delete_context = _.extend this, | |
s3_delete_path:path | |
auth_function = _.bind S3.rules.delete,delete_context | |
if not auth_function() | |
throw new Meteor.Error "Unauthorized", "Delete not allowed" | |
params = | |
Bucket: path.split('/')[1] | |
Key: path.split('/')[2] | |
S3.aws.deleteObject params, (e,r) -> | |
if e | |
future.return e | |
else | |
future.return true | |
future.wait() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Docs: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#deleteObject-property