useXMLHttpService
This hook is used to provide a uploadService to your FileUpload components.
The name of this hook is a bit of a misnamor as it has nothing to do with XML specifically. Rather the name indicates that it uses
the XMLHttpRequest.
The reason it uses XMLHttpRequest over
something like fetch
is because it allows for tracking upload progress.
Returns: FileUploadService<Response>
Required Arguments
endpoint string
The endpoint where the file upload api exists.
Optional Arguments
method string
The http method for the file upload api, aka "POST", "PUT", etc.
Default: "POST"
modifyRequest (xhr: XMLHttpRequest) => Promise<void> | void
This is useful when you need add headers to the request. Such as Authorization header
A function that can be used to modify the request.
responseTransformer (responseText: string) => Response
Used to transform response body to whatever you need. Typically Response type is a string indicating a url point to the file which has been uploaded. This allows you to take whatever your response is for the API (JSON, XML, etc) and get the link to the file which was uploaded.