forked from SaltwaterC/aws2js
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a multipart upload test for the S3 Multipart Upload API.
- Loading branch information
1 parent
8fb35f1
commit 24afc96
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var cp = require('child_process'); | ||
var assert = require('assert'); | ||
var crypto = require('crypto'); | ||
var fs = require('fs'); | ||
var s3 = require('../').load('s3'); | ||
|
||
s3.setCredentials(process.env.AWS_ACCEESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY); | ||
s3.setBucket(process.env.AWS2JS_S3_BUCKET); | ||
|
||
cp.execFile('../tools/createtemp.sh', function (err, res) { | ||
assert.ifError(err); | ||
var tempMd5 = res.replace(/\s/g, ''); | ||
s3.putFileMultipart('10M.tmp', './10M.tmp', false, {}, 5242880, function (err, res) { | ||
assert.ifError(err); | ||
s3.get('10M.tmp', {file: './10M.tmp'}, function (err, res) { | ||
assert.ifError(err); | ||
var md5 = crypto.createHash('md5'); | ||
var rs = fs.ReadStream('./10M.tmp'); | ||
rs.on('data', function (data) { | ||
md5.update(data); | ||
}); | ||
rs.on('end', function () { | ||
var dlMd5 = md5.digest('hex'); | ||
assert.deepEqual(tempMd5, dlMd5); | ||
fs.unlink('./10M.tmp', function (err) { | ||
assert.ifError(err); | ||
}); | ||
}); | ||
rs.on('error', function (err) { | ||
assert.ifError(err); | ||
}); | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
dd if=/dev/urandom of=10M.tmp bs=1M count=10 2>/dev/null | ||
md5sum 10M.tmp | cut -d' ' -f1 |