How to access the file or file name in XHR plugin onBeforeRequest?

In XHR plugin “onBeforeRequest” I fetch a token, and included in that response is the bucket name to which i upload the images.

Taking the bucket name, I construct the endpoint to send the image to, However, I am required to include the file name in the endpoint as a queryParam but I do not have access to the file to get the name here.

Reading conversations on here it seems that file was added as the second argument to onBeforeRequest, but has been removed in the latest version. Is that correct?

How would I access the file or file name in onBeforeRequest? Or is it not possible to associate the request with a file?

Thanks

async onBeforeRequest(xhr, retryCount) {

          const res = await fetchToken(); 
          const token = res.token
          const bucket = res.bucket

          // How to get actual file name here?
          const fileName = "file-name.jpg"

          const BASE_URL = `https://www.some-endpoint.com/${BUCKET}`
          const queryParams = `name=${encodeURIComponent(fileName)}`;

          const URL = BASE_URL + '?' + queryParams;

          xhr.open("POST", URL, true);
          xhr.setRequestHeader("Authorization", `Bearer ${TOKEN}`)
        },

I’ve just noticed that “file” is the second param of onBeforeRequest in the Tus plugin, not XHR plugin.

If file was second param in XHR plugin onBeforeRequest that would solve it for me. Currently no way of associating the request with the file

Good point, we should pass file as well.

Awesome. Tried creating a pr but didn’t have permission to push

Open source contributions are always done via forks: How to Contribute to Open Source | Open Source Guides

There is a PR for this: @uppy/xhr-upload: pass files to onBeforeRequest by Murderlon · Pull Request #5447 · transloadit/uppy · GitHub

Awesome, much appreciated