Momentum logo
Team 10 Classroom

🦊 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)

πŸ“– Read | πŸ“Ί Watch | 🎧 Listen

πŸ”– Resources

Back to home