Multiple destination depending of filetype (AWS & XHR)


I’m looking for a way do dynamically change the destination of the upload depending of the filetype.

The case is : Dashboard allowing .MP3 and .WAV.
User can send both filetype in the same instance.
IF it’s an mp3, file are uploaded to AWS S3 with the AWSS3 plugin.
If it’s wav, file are send to another server by sftp (PHP upload) with XHR plugin.

IF i send only MP3, all work.
If i send only WAV, this is also working.
But if it’s mixed filetype, all is uploaded to AWS.

Did not find info in documentation.
Maybe it should be better to use only one endpoint, and handle the S3 upload from this endpoint instead using the AwSS3 plugin ?

 uppy.on('upload', () => {
      uppy.getFiles().forEach(file => {
        if('wav' === file.extension) {
          console.log('it is a wav')
          const S3Active = uppy.getPlugin('AwsS3')
          if(S3Active) uppy.removePlugin(S3Active)
          const ajaxActive = uppy.getPlugin('XHRUpload')
          if(!ajaxActive) use_ajax();
          console.log('it is a mp3')
          const ajaxActive = uppy.getPlugin('XHRUpload')
          if(ajaxActive) uppy.removePlugin(ajaxActive)
          const S3Active = uppy.getPlugin('AwsS3')
          if(!S3Active) use_aws()



function use_ajax(){
          endpoint: ajaxurl+'?action=plupload_wav',
          limit: 1,
          formData: true,
          fieldName: 'file'

function use_aws() {
    uppy.use(Uppy.AwsS3, {
        getUploadParameters (file) {
          // Send a request to our PHP signing endpoint.
          return fetch(ajaxurl+'?action=presigned_url', {
            method: 'post',
            // Send and receive JSON.
            headers: {
              accept: 'application/json',
              'content-type': 'application/json'
            body: JSON.stringify({
              contentType: file.type
          }).then((response) => {
            // Parse the JSON response.
            return response.json()
          }).then((data) => {
            // Return an object in the correct shape.
            return {
              method: data.method,
              url: data.url,
              fields: data.fields,
              // Provide content type header required by S3
              headers: {
                'Content-Type': file.type