Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Commit 4a4498b

Browse files
committed
Add support for ctor body functions
1 parent 6ad6342 commit 4a4498b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/deploy/upload-files.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async function uploadFiles(api, deployId, uploadList, { concurrentUpload, status
1313

1414
const uploadFile = async (fileObj, index) => {
1515
const { normalizedPath, assetType, runtime } = fileObj
16-
const readStream = fs.createReadStream(fileObj.filepath)
16+
const readStreamCtor = () => fs.createReadStream(fileObj.filepath)
1717

1818
statusCb({
1919
type: 'upload',
@@ -26,7 +26,7 @@ async function uploadFiles(api, deployId, uploadList, { concurrentUpload, status
2626
response = await retryUpload(
2727
() =>
2828
api.uploadDeployFile({
29-
body: readStream,
29+
body: readStreamCtor,
3030
deployId,
3131
path: encodeURI(normalizedPath)
3232
}),
@@ -38,7 +38,7 @@ async function uploadFiles(api, deployId, uploadList, { concurrentUpload, status
3838
response = await await retryUpload(
3939
() =>
4040
api.uploadDeployFunction({
41-
body: readStream,
41+
body: readStreamCtor,
4242
deployId,
4343
name: encodeURI(normalizedPath),
4444
runtime

src/open-api/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ exports.generateMethod = method => {
9292
let response
9393
try {
9494
debug(`requesting ${path}`)
95-
response = await fetch(path, opts)
95+
96+
// Pass in a function for readable stream ctors
97+
const fetchOpts = typeof opts.body === 'function' ? Object.assign({}, opts, { body: opts.body() }) : opts
98+
99+
response = await fetch(path, fetchOpts)
96100
} catch (e) {
97101
// TODO: clean up this error path
98102
debug(`fetch error`)

0 commit comments

Comments
 (0)