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

Commit

Permalink
Export both uploadToS3 functions so that they can be reused by third-…
Browse files Browse the repository at this point in the history
…parties
  • Loading branch information
stefanoverna committed Nov 4, 2021
1 parent 0095fc3 commit ad8acad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/upload/adapters/browser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function uploadToS3(file, url, { onProgress }) {
export function uploadToS3(file, url, { onProgress }) {
const xhr = new XMLHttpRequest();

const promise = new Promise((resolve, reject) => {
Expand Down
4 changes: 3 additions & 1 deletion src/upload/adapters/node.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import url from 'url';
import fs from 'fs';
import remote from './nodeRemote';
import local from './nodeLocal';
import local, { uploadToS3 } from './nodeLocal';

export { uploadToS3 };

export default function node(client, source, options = {}) {
const { host } = url.parse(source);
Expand Down
4 changes: 2 additions & 2 deletions src/upload/adapters/nodeLocal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path';
import fs from 'fs';
import mime from 'mime-types';

function uploadToS3(url, filePath, { onProgress }) {
export function uploadToS3(filePath, url, { onProgress }) {
const totalLength = fs.statSync(filePath).size;
let isCancelled = false;
const promise = got.put(url, {
Expand Down Expand Up @@ -60,8 +60,8 @@ export default function nodeLocal(client, filePath, options) {
});
}
const { promise: uploadPromise, cancel: cancelUpload } = uploadToS3(
url,
filePath,
url,
{
onProgress: options.onProgress,
},
Expand Down

0 comments on commit ad8acad

Please sign in to comment.