 
 	directorySize:(bucketName, key, callback)->
 		logger.log bucketName:bucketName, key:key, "get project size in s3"
-		s3Client = knox.createClient
-			key: settings.filestore.s3.key
-			secret: settings.filestore.s3.secret
-			bucket: bucketName
+		s3Client = getKnoxClient(bucketName)
 		s3Client.list prefix:key, (err, data)->
 			if err?
 				logger.err err:err, bucketName:bucketName, key:key, "something went wrong listing prefix in aws"

			_callback = () ->

		logger.log key: key, bucketName: bucketName, "deleting directory"
		s3Client = knox.createClient
			key: settings.filestore.s3.key
			secret: settings.filestore.s3.secret
			bucket: bucketName
		s3Client.list prefix:key, (err, data)->
			if err?
				logger.err err:err, bucketName:bucketName, key:key, "something went wrong listing prefix in aws"

Errors = require("./Errors")
_ = require("underscore")
awsS3 = require "aws-sdk/clients/s3"
URL = require('url')

thirtySeconds = 30 * 1000

buildDefaultOptions = (bucketName, method, key)->
	if settings.filestore.s3.endpoint
		endpoint = "#{settings.filestore.s3.endpoint}/#{bucketName}"
	else
		endpoint = "https://#{bucketName}.s3.amazonaws.com"
	return {
			aws:
				key: settings.filestore.s3.key
