Support metadata when uploading objects

Add contentType and contentEncoding options to sendStream(). These
options will set the corresponding metadata on the object.

This changes the API. The fourth argument to sendStream() used to be the
source md5. Now, it's an options object and the source md5 is a property
of that object.
This commit is contained in:
Eric Mc Sween
2020-07-08 08:13:53 -04:00
parent cd8c8b2b7f
commit 523ff9c4cd
10 changed files with 95 additions and 41 deletions
+5 -2
View File
@@ -37,7 +37,7 @@ const { Errors } = ObjectPersistor
#### sendStream
```JavaScript
async function sendStream(bucketName, key, readStream, sourceMd5 = null)
async function sendStream(bucketName, key, readStream, opts = {})
```
Uploads a stream to the backend.
@@ -45,7 +45,10 @@ Uploads a stream to the backend.
- `bucketName`: The name of the bucket to upload to
- `key`: The key for the uploaded object
- `readStream`: The data stream to upload
- `sourceMd5` (optional): The md5 hash of the source data, if known. The uploaded data will be compared against this and the operation will fail if it does not match. If omitted, the md5 is calculated as the data is uploaded instead, and verified against the backend.
- `opts` (optional):
- `sourceMd5`: The md5 hash of the source data, if known. The uploaded data will be compared against this and the operation will fail if it does not match. If omitted, the md5 is calculated as the data is uploaded instead, and verified against the backend.
- `contentType`: The content type to write in the object metadata
- `contentEncoding`: The content encoding to write in the object metadata
##### Notes