Преглед изворни кода

Move S3 Multipart upload to a separate package.

Renée Kooi пре 6 година
родитељ
комит
a0798cf5ee

+ 21 - 0
packages/@uppy/aws-s3-multipart/LICENSE

@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2018 Transloadit
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 41 - 0
packages/@uppy/aws-s3-multipart/README.md

@@ -0,0 +1,41 @@
+# @uppy/aws-s3-multipart
+
+<img src="https://uppy.io/images/logos/uppy-dog-head-arrow.svg" width="120" alt="Uppy logo: a superman puppy in a pink suit" align="right">
+
+<a href="https://www.npmjs.com/package/@uppy/aws-s3-multipart"><img src="https://img.shields.io/npm/v/@uppy/aws-s3-multipart.svg?style=flat-square"></a>
+<a href="https://travis-ci.org/transloadit/uppy"><img src="https://img.shields.io/travis/transloadit/uppy/master.svg?style=flat-square" alt="Build Status"></a>
+
+The AwsS3Multipart plugin can be used to upload files directly to an S3 bucket using S3’s Multipart upload strategy. With this strategy, files are chopped up in parts of 5MB+ each, so they can be uploaded concurrently. It’s also very reliable: if a single part fails to upload, only that 5MB has to be retried.
+
+Uppy is being developed by the folks at [Transloadit](https://transloadit.com), a versatile file encoding service.
+
+## Example
+
+```js
+const Uppy = require('@uppy/core')
+const AwsS3Multipart = require('@uppy/aws-s3-multipart')
+
+const uppy = Uppy()
+uppy.use(AwsS3Multipart, {
+  limit: 2,
+  serverUrl: 'https://uppy-server.myapp.com/'
+})
+```
+
+## Installation
+
+```bash
+$ npm install @uppy/aws-s3-multipart --save
+```
+
+We recommend installing from npm and then using a module bundler such as [Webpack](http://webpack.github.io/), [Browserify](http://browserify.org/) or [Rollup.js](http://rollupjs.org/).
+
+Alternatively, you can also use this plugin in a pre-built bundle from Transloadit's CDN: Edgly. In that case `Uppy` will attach itself to the global `window.Uppy` object. See the [main Uppy documentation](https://uppy.io/docs/#Installation) for instructions.
+
+## Documentation
+
+Documentation for this plugin can be found on the [Uppy website](https://uppy.io/docs/aws-s3-multipart).
+
+## License
+
+[The MIT License](./LICENSE).

+ 37 - 0
packages/@uppy/aws-s3-multipart/package.json

@@ -0,0 +1,37 @@
+{
+  "name": "@uppy/aws-s3-multipart",
+  "description": "Upload to Amazon S3 with Uppy and S3's Multipart upload strategy",
+  "version": "0.25.5",
+  "license": "MIT",
+  "main": "lib/index.js",
+  "jsnext:main": "src/index.js",
+  "types": "types/index.d.ts",
+  "keywords": [
+    "file uploader",
+    "aws s3",
+    "amazon s3",
+    "s3",
+    "uppy",
+    "uppy-plugin",
+    "multipart"
+  ],
+  "homepage": "https://uppy.io",
+  "bugs": {
+    "url": "https://github.com/transloadit/uppy/issues"
+  },
+  "repository": {
+    "type": "git",
+    "url": "git+https://github.com/transloadit/uppy.git"
+  },
+  "dependencies": {
+    "@uppy/server-utils": "^0.25.5",
+    "@uppy/utils": "^0.25.5",
+    "resolve-url": "^0.2.1"
+  },
+  "devDependencies": {
+    "@uppy/core": "^0.25.5"
+  },
+  "peerDependencies": {
+    "@uppy/core": "^0.25.5"
+  }
+}

+ 0 - 0
packages/@uppy/aws-s3/src/MultipartUploader.js → packages/@uppy/aws-s3-multipart/src/MultipartUploader.js


+ 0 - 0
packages/@uppy/aws-s3/src/Multipart.js → packages/@uppy/aws-s3-multipart/src/index.js


+ 22 - 0
packages/@uppy/aws-s3-multipart/types/index.d.ts

@@ -0,0 +1,22 @@
+import { Plugin, PluginOptions, Uppy } from '@uppy/core';
+
+export interface AwsS3Part {
+  PartNumber: number;
+  Size: number;
+  ETag: string;
+}
+
+export interface AwsS3MultipartOptions extends PluginOptions {
+  serverUrl: string;
+  createMultipartUpload(file: object): Promise<{uploadId: string, key: string}>;
+  listParts(opts: {uploadId: string, key: string}): Promise<AwsS3Part>;
+  prepareUploadPart(partData: {uploadId: string, key: string, body: Blob, number: number}): Promise<{url: string}>;
+  abortMultipartUpload(opts: {uploadId: string, key: string}): Promise<void>;
+  completeMultipartUpload(opts: {uploadId: string, key: string, parts: AwsS3Part[]}): Promise<{location?: string}>;
+  timeout: number;
+  limit: number;
+}
+
+export default class AwsS3Multipart extends Plugin {
+  constructor(uppy: Uppy, opts: Partial<AwsS3MultipartOptions>);
+}

+ 1 - 0
packages/uppy/index.js

@@ -28,6 +28,7 @@ exports.Webcam = require('@uppy/webcam')
 
 // Uploaders
 exports.AwsS3 = require('@uppy/aws-s3')
+exports.AwsS3Multipart = require('@uppy/aws-s3-multipart')
 exports.Transloadit = require('@uppy/transloadit')
 exports.Tus = require('@uppy/tus')
 exports.XHRUpload = require('@uppy/xhrupload')

+ 1 - 0
packages/uppy/index.mjs

@@ -27,6 +27,7 @@ export { default as Webcam } from '@uppy/webcam'
 
 // Uploaders
 export { default as AwsS3 } from '@uppy/aws-s3'
+export { default as AwsS3Multipart } from '@uppy/aws-s3-multipart'
 export { default as Transloadit } from '@uppy/transloadit'
 export { default as Tus } from '@uppy/tus'
 export { default as XHRUpload } from '@uppy/xhrupload'

+ 1 - 0
packages/uppy/package.json

@@ -31,6 +31,7 @@
   },
   "dependencies": {
     "@uppy/aws-s3": "0.25.5",
+    "@uppy/aws-s3-multipart": "0.25.5",
     "@uppy/core": "0.25.5",
     "@uppy/dashboard": "0.25.5",
     "@uppy/drag-drop": "0.25.5",

+ 1 - 0
packages/uppy/types/index.d.ts

@@ -27,6 +27,7 @@ declare module 'uppy' {
 
   // Uploaders
   export { default as AwsS3 } from '@uppy/aws-s3';
+  export { default as AwsS3Multipart } from '@uppy/aws-s3-multipart';
   export { default as Transloadit } from '@uppy/transloadit';
   export { default as Tus } from '@uppy/tus';
   export { default as XHRUpload } from '@uppy/xhrupload';