File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -306,18 +306,25 @@ const query = await ddb.send(new QueryCommand({
306
306
307
307
#### Lib Storage Upload
308
308
309
- To mock ` @aws-sdk/lib-storage ` ` Upload ` you need to mock
310
- at least two commands: ` CreateMultipartUploadCommand ` and ` UploadPartCommand `
309
+ To mock ` @aws-sdk/lib-storage ` ` Upload ` you need to mock all commands
311
310
used [ under the hood] ( https://github.com/aws/aws-sdk-js-v3/blob/main/lib/lib-storage/src/Upload.ts ) :
312
311
313
312
``` typescript
314
313
import {S3Client , CreateMultipartUploadCommand , UploadPartCommand } from ' @aws-sdk/client-s3' ;
315
314
import {Upload } from " @aws-sdk/lib-storage" ;
316
315
317
316
const s3Mock = mockClient (S3Client );
317
+
318
+ // for big files upload:
318
319
s3Mock .on (CreateMultipartUploadCommand ).resolves ({UploadId: ' 1' });
319
320
s3Mock .on (UploadPartCommand ).resolves ({ETag: ' 1' });
320
321
322
+ // for small files upload:
323
+ s3ClientMock .on (PutObjectCommand ).callsFake (async (input , getClient ) => {
324
+ getClient ().config .endpoint = () => ({hostname: " " }) as any ;
325
+ return {};
326
+ });
327
+
321
328
const s3Upload = new Upload ({
322
329
client: new S3Client ({}),
323
330
params: {
You can’t perform that action at this time.
0 commit comments