Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

download string as file express js

app.get('/download', (request, response) => {
  const fileData = 'SGVsbG8sIFdvcmxkIQ=='
  const fileName = 'hello_world.txt'
  const fileType = 'text/plain'

  response.writeHead(200, {
    'Content-Disposition': `attachment; filename="${fileName}"`,
    'Content-Type': fileType,
  })

  const download = Buffer.from(fileData, 'base64')
  response.end(download)
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: Javascript function method with any number of arguments 
Javascript :: javascript true string to boolean 
Javascript :: how to make html with jquery 
Javascript :: javascript online compiler 
Javascript :: How to remove CSS file using JavaScript 
Javascript :: delete an item from array javascript 
Javascript :: base64 js vanilla 
Javascript :: Symbol Methods javascript 
Javascript :: angular 12 features 
Javascript :: using sequelize to read from a table 
Javascript :: array from js 
Javascript :: get search value from reacr route3 
Javascript :: column cannot be cast automatically to type bigint postgres sequelize 
Javascript :: {"statusCode":400,"error":"Bad Request","message":"Unexpected token o in JSON at position 1"} 
Javascript :: javascript compare timestamp 
Javascript :: javascript for pop up 
Javascript :: open dev server 
Javascript :: how to create object js 
Javascript :: react firebase add doc to collection 
Javascript :: feet to inches 
Javascript :: even.target in javascript 
Javascript :: how to coerce a string to number in javascript 
Javascript :: array.map 
Javascript :: javascript stringify blob 
Javascript :: multiple image upload react 
Javascript :: js splice 
Javascript :: react-particles-js not working 
Javascript :: slice string javascript if has @ 
Javascript :: array.length 
Javascript :: loop over documents in mongoose 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =