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}`)
},