Fix the check for a success response from S3.

We need to handle both a 200 and 206 (partial content) response.
This commit is contained in:
Shane Kilkelly 2015-09-01 12:25:10 +01:00
parent 82af1be756
commit 9b8f11f517

View file

@ -77,8 +77,8 @@ module.exports =
if res.statusCode == 404 if res.statusCode == 404
logger.log bucketName:bucketName, key:key, "file not found in s3" logger.log bucketName:bucketName, key:key, "file not found in s3"
return callback new Errors.NotFoundError("File not found in S3: #{bucketName}:#{key}"), null return callback new Errors.NotFoundError("File not found in S3: #{bucketName}:#{key}"), null
if res.stausCode != 200 if res.statusCode not in [200, 206]
logger.log bucketName:bucketName, key:key, "error getting file from s3" logger.log bucketName:bucketName, key:key, "error getting file from s3: #{res.statusCode}"
return callback new Error("Got non-200 response from S3: #{res.statusCode}"), null return callback new Error("Got non-200 response from S3: #{res.statusCode}"), null
callback null, res callback null, res
s3Stream.on 'error', (err) -> s3Stream.on 'error', (err) ->