Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. // Download file from storage
  2. app.get('/getDataFromStorageFile', (req, res) => {
  3. console.log(req.query.uid)
  4. return admin.storage().bucket()
  5. .file(`/development/resumes/123.html`).download()
  6. .then(data => {
  7. // This renders the content as html if it was stored as html
  8. return res.send(data[0].toString())
  9. })
  10. .catch(e => {
  11. return res.json({
  12. status: 'failed: ' + e.message
  13. })
  14. })
  15. })
  16.  
  17. // Download file from storage
  18. app.post('/uploadDataToStorage', (req, res) => {
  19. return admin.storage().bucket()
  20. .file('/development/resumes/resume').save(req.params.body)
  21. .then(() => {
  22. return res.json({status: 'success'})
  23. })
  24. .catch(e => {
  25. return res.json({status: 'failed: ' + e.message})
  26. })
  27. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement