Quellcode durchsuchen

Revert "Merge pull request #1550 from transloadit/remove-default-protocol"

This reverts commit 3dd930d658d8f3f97a72c2b30f0901eb106b260f, reversing
changes made to d1b5cc060216964a8395759bee2412ac1ad40c23.
Ifedapo Olarewaju vor 6 Jahren
Ursprung
Commit
248af15a8a

+ 0 - 1
CHANGELOG.md

@@ -106,7 +106,6 @@ PRs are welcome! Please do open an issue to discuss first if it's a big feature,
 - [ ] QA: add one integration test (or add to existing test) that uses more exotic (tus) options such as `useFastRemoteRetry` or `removeFingerprintOnSuccess` https://github.com/transloadit/uppy/issues/1327 (@arturi, @ifedapoolarewaju)
 - [x] @uppy/companion: investigate 423 and 500 issues with React Native + Url plugin when pause/resuming an upload
 - [x] companion: remove deprecated "authorized" endpoint
-- [x] companion: remove default upload protocol
 - [x] companion: remove fallback `UPPYSERVER_*` env options
 - [x] companion: change OAuth access token transport
 

+ 2 - 6
packages/@uppy/companion/src/server/Uploader.js

@@ -93,11 +93,6 @@ class Uploader {
    * @returns {boolean}
    */
   validateOptions (options) {
-    if (!Object.keys(PROTOCOLS).some((key) => PROTOCOLS[key] === options.protocol)) {
-      this._errRespMessage = 'Invalid upload protocol'
-      return false
-    }
-
     // s3 uploads don't require upload destination
     // validation, because the destination is determined
     // by the server's s3 config
@@ -162,7 +157,8 @@ class Uploader {
    * @param {Buffer | Buffer[]} chunk
    */
   handleChunk (chunk) {
-    const protocol = this.options.protocol
+    // @todo a default protocol should not be set. We should ensure that the user specifies her protocol.
+    const protocol = this.options.protocol || PROTOCOLS.multipart
 
     // The download has completed; close the file and start an upload if necessary.
     if (chunk === null) {

+ 0 - 11
packages/@uppy/companion/test/__tests__/companion.js

@@ -63,17 +63,6 @@ describe('download provdier file', () => {
       .expect(200)
       .then((res) => expect(res.body.token).toBeTruthy())
   })
-
-  test('download should fail if protocol is not specified', () => {
-    return request(authServer)
-      .post('/drive/get/README.md')
-      .set('uppy-auth-token', token)
-      .set('Content-Type', 'application/json')
-      .send({
-        endpoint: 'http://master.tus.com/files'
-      })
-      .expect(400)
-  })
 })
 
 describe('test authentication', () => {

+ 0 - 1
packages/@uppy/xhr-upload/src/index.js

@@ -324,7 +324,6 @@ module.exports = class XHRUpload extends Plugin {
         file.remote.url,
         Object.assign({}, file.remote.body, {
           endpoint: opts.endpoint,
-          protocol: 'multipart',
           size: file.data.size,
           fieldname: opts.fieldName,
           metadata: fields,