Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- config = require 'config'
- s3 = require 's3'
- q = require 'q'
- module.export = (oldKey, newKey) ->
- defer = q.defer()
- params =
- # you need to set the s3 bucket in the CopySource key
- CopySource: "#{ config.s3.bucket }/#{ oldKey }"
- Key: newKey
- s3.copyObject params, (err) ->
- if err then defer.reject(err)
- else s3.deleteObject Key: oldKey, (err) ->
- if err then defer.reject(err)
- else defer.resolve()
- return defer.promise
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement