File tree Expand file tree Collapse file tree 3 files changed +44
-3
lines changed Expand file tree Collapse file tree 3 files changed +44
-3
lines changed Original file line number Diff line number Diff line change @@ -147,3 +147,9 @@ var UploadStreamObject = new Uploader(
147
147
```
148
148
npm install s3-upload-stream
149
149
```
150
+
151
+ ### Running Tests
152
+
153
+ ```
154
+ npm test
155
+ ```
Original file line number Diff line number Diff line change @@ -43,15 +43,15 @@ module.exports = {
43
43
self . receivedSize = 0 ;
44
44
self . uploadedSize = 0 ;
45
45
self . currentPart = Buffer ( 0 ) ;
46
- self . maxPartSize = 5242880 ;
46
+ self . partSizeThreshold = 5242880 ;
47
47
48
48
// Set the maximum amount of data that we will keep in memory before flushing it to S3 as a part
49
49
// of the multipart upload
50
50
self . maxPartSize = function ( partSize ) {
51
51
if ( partSize < 5242880 )
52
52
partSize = 5242880 ;
53
53
54
- self . maxPartSize = partSize ;
54
+ self . partSizeThreshold = partSize ;
55
55
} ;
56
56
57
57
// Handler to receive data and upload it to S3.
@@ -60,7 +60,7 @@ module.exports = {
60
60
61
61
// If the current Part buffer is getting too large, or the stream piped in has ended then flush
62
62
// the Part buffer downstream to S3 via the multipart upload API.
63
- if ( self . currentPart . length > self . maxPartSize )
63
+ if ( self . currentPart . length > self . partSizeThreshold )
64
64
self . flushPart ( next ) ;
65
65
else
66
66
next ( ) ;
Original file line number Diff line number Diff line change @@ -162,6 +162,41 @@ describe('Creating upload stream', function () {
162
162
} ) ;
163
163
} ) ;
164
164
165
+ describe ( 'Stream Methods' , function ( ) {
166
+ var uploadStream , uploadObject ;
167
+
168
+ before ( function ( done ) {
169
+ uploadObject = new UploadStream (
170
+ {
171
+ s3Client : new AWSstub . S3 ( )
172
+ } ,
173
+ {
174
+ "Bucket" : "test-bucket-name" ,
175
+ "Key" : "test-file-name"
176
+ } ,
177
+ function ( err , data ) {
178
+ expect ( err ) . to . equal ( null ) ;
179
+ uploadStream = data ;
180
+ done ( ) ;
181
+ }
182
+ ) ;
183
+ } ) ;
184
+
185
+ describe ( 'Setting max part size to a value greater than 5 MB' , function ( ) {
186
+ it ( 'max part size should be set to that value' , function ( ) {
187
+ uploadObject . maxPartSize ( 20971520 ) ;
188
+ expect ( uploadObject . partSizeThreshold ) . to . equal ( 20971520 ) ;
189
+ } ) ;
190
+ } ) ;
191
+
192
+ describe ( 'Setting max part size to a value less than 5 MB' , function ( ) {
193
+ it ( 'max part size should be set to 5 MB exactly' , function ( ) {
194
+ uploadObject . maxPartSize ( 4242880 ) ;
195
+ expect ( uploadObject . partSizeThreshold ) . to . equal ( 5242880 ) ;
196
+ } ) ;
197
+ } ) ;
198
+ } ) ;
199
+
165
200
describe ( 'Piping data into the upload stream' , function ( ) {
166
201
var uploadStream , uploadObject ;
167
202
You can’t perform that action at this time.
0 commit comments