Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: a6acf7ecfd
Fetching contributors…

Cannot retrieve contributors at this time

62 lines (44 sloc) 1.553 kb
class Tower.StoreS3 extends Tower.Store
client: ->
return @_client if @_client
knox = require('knox')
@_client = knox.createClient Tower.config.credentials.s3
insert: (cursor, callback) ->
files = [cursor]
client = @client()
mime = require('mime')
fs = require('fs')
create = (file, next) =>
# tmp
delete file._data
return next(new Error('Must specify the upload path,, for ' + file.path)) unless
fs.stat file.path, (error, stats) =>
file.length = stats.size
# @todo far-future expires headers
headers =
'Content-Length': file.length,
'Content-Type': file.mime || mime.lookup(file.filename)
'x-amz-acl': 'public-read'
upload = =>
stream = fs.createReadStream(file.path)
client.putStream stream,, headers, (error, response) =>
Tower.series files, create, (error) =>, error) if callback
create: ->
@insert arguments...
update: (updates, cursor, callback) ->
destroy: (cursor, callback) ->
paths = _.castArray(cursor)
client = @client()
destroy = (path, next) =>
return next() unless path?
client.deleteFile(path, next)
Tower.series paths, destroy, (error) =>, error) if callback
createDatabase: ->
createBucket: ->
module.exports = Tower.StoreS3
Jump to Line
Something went wrong with that request. Please try again.