s3-upload-stream typing

This commit is contained in:
Joshua DeVinney
2016-09-04 21:12:52 -05:00
parent f80ef83201
commit 7cfc95d09a
3 changed files with 66 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
// Type definitions for s3-upload-stream
// Project: https://github.com/nathanpeck/s3-upload-stream
// Definitions by: Joshua DeVinney <https://github.com/geoffreak>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
/// <reference path="../aws-sdk/index.d.ts" />
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;
@@ -0,0 +1,21 @@
/// <reference types="node" />
/// <reference path="../aws-sdk/index.d.ts" />
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);
+19
View File
@@ -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"
]
}