π¦ Search and File Uploads π¦
Posted on Dec 21st, 2021
ποΈ Todayβs Topics
- Implementing search in your application π
- Images
- File Uploads: forms and requests
Example Request to Upload a File
This is an update (notice the PUT verb) to an existing record. In this case you are including the file itself as the body of the request (notice it in the second position as an argument to put()
) and setting specific headers required by the server to handle the binary file attachment.
axios.put(url, file, {
headers: {
Authorization: 'Token ' + token,
'Content-Type': file.type,
'Content-Disposition': `attachment; filename=${file.name}`
}
}).then(res = res.data)