Jelajahi Sumber

Merge pull request #181 from goto-bus-stop/tus-remote-upload-endpoint

tus: Also use the endpoint from the `file.tus` property in remote uploads
Artur Paikin 8 tahun lalu
induk
melakukan
f6cff30122
1 mengubah file dengan 7 tambahan dan 1 penghapusan
  1. 7 1
      src/plugins/Tus10.js

+ 7 - 1
src/plugins/Tus10.js

@@ -177,6 +177,11 @@ module.exports = class Tus10 extends Plugin {
   uploadRemote (file, current, total) {
     return new Promise((resolve, reject) => {
       this.core.log(file.remote.url)
+      let endpoint = this.opts.endpoint
+      if (file.tus && file.tus.endpoint) {
+        endpoint = file.tus.endpoint
+      }
+
       fetch(file.remote.url, {
         method: 'post',
         credentials: 'include',
@@ -185,9 +190,10 @@ module.exports = class Tus10 extends Plugin {
           'Content-Type': 'application/json'
         },
         body: JSON.stringify(Object.assign({}, file.remote.body, {
-          endpoint: this.opts.endpoint,
+          endpoint,
           protocol: 'tus',
           size: file.data.size
+          // TODO add `file.meta` as tus metadata here
         }))
       })
       .then((res) => {