From 7cfc95d09aee4600d6201d7a937eaa269d184c02 Mon Sep 17 00:00:00 2001 From: Joshua DeVinney Date: Sun, 4 Sep 2016 21:06:54 -0500 Subject: [PATCH] s3-upload-stream typing --- s3-upload-stream/index.d.ts | 26 ++++++++++++++++++++++ s3-upload-stream/s3-upload-stream-tests.ts | 21 +++++++++++++++++ s3-upload-stream/tsconfig.json | 19 ++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 s3-upload-stream/index.d.ts create mode 100644 s3-upload-stream/s3-upload-stream-tests.ts create mode 100644 s3-upload-stream/tsconfig.json diff --git a/s3-upload-stream/index.d.ts b/s3-upload-stream/index.d.ts new file mode 100644 index 0000000000..530fff9674 --- /dev/null +++ b/s3-upload-stream/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for s3-upload-stream +// Project: https://github.com/nathanpeck/s3-upload-stream +// Definitions by: Joshua DeVinney +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +import * as stream from 'stream'; +import * as AWS from 'aws-sdk'; + +interface IS3Stream { + (client: AWS.S3): IS3StreamUploader +} + +interface IS3StreamUploader { + upload(destinationDetails: AWS.s3.PutObjectRequest, sessionDetails?: any): IS3WriteStream; +} + +interface IS3WriteStream extends stream.Writable { + maxPartSize(sizeInBytes: number): void; + concurrentParts(numberOfParts: number): void; +} + +declare var s3Stream: IS3Stream; +export = s3Stream; diff --git a/s3-upload-stream/s3-upload-stream-tests.ts b/s3-upload-stream/s3-upload-stream-tests.ts new file mode 100644 index 0000000000..fefae6782e --- /dev/null +++ b/s3-upload-stream/s3-upload-stream-tests.ts @@ -0,0 +1,21 @@ +/// +/// + +import * as fs from 'fs'; +import * as S3Stream from 's3-upload-stream'; +import * as AWS from 'aws-sdk'; + +var s3Stream = S3Stream(new AWS.S3()); + +var read = fs.createReadStream('/path/to/a/file'); +var upload = s3Stream.upload({ + Bucket: "bucket-name", + Key: "key-name", + ACL: "public-read", + StorageClass: "REDUCED_REDUNDANCY", + ContentType: "binary/octet-stream" +}); + +upload.concurrentParts(5); + +read.pipe(upload); diff --git a/s3-upload-stream/tsconfig.json b/s3-upload-stream/tsconfig.json new file mode 100644 index 0000000000..01c892ab5c --- /dev/null +++ b/s3-upload-stream/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "s3-upload-stream-tests.ts" + ] +} \ No newline at end of file