Guest User

Untitled

a guest
Feb 24th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. const avatarId = this.Uuid(),
  2. sharp = this.Sharp({failOnError: true}),
  3. instream = this.GoogleCloudStorage.GET(this.GoogleCloudStorage.getName(photo.uri)),
  4. fileLocation = this.getTempFileLocation()
  5.  
  6. sharp.rotate().extract({left: x, top: y, width: w, height: w})
  7. if (w > 600) {
  8. sharp.resize(600, 600, {fastShrinkOnLoad: false})
  9. w = 600
  10. }
  11.  
  12. instream.pipe(sharp)
  13. return sharp.jpeg().toFile(fileLocation)
  14. .then( info => {
  15. console.log('editAvatar: sharp done')
  16. return this.GoogleCloudStorage.POST( avatarId, this.Fs.createReadStream( fileLocation ), this.getMIMEType(info) )
  17. } )
  18.  
  19. [02/24/2018 07:41:06.892] Error -- message: Input file is missing or of an unsupported image format -- stack: Error: Input file is missing or of an unsupported image format
  20. events.js:163
  21. throw er; // Unhandled 'error' event
  22. ^
  23.  
  24. Error: Unexpected data on Writable Stream
  25. at Sharp._write (/code/api/node_modules/sharp/lib/input.js:114:14)
  26. at doWrite (_stream_writable.js:329:12)
  27. at writeOrBuffer (_stream_writable.js:315:5)
  28. at Sharp.Writable.write (_stream_writable.js:241:11)
  29. at DestroyableTransform.ondata (/code/api/node_modules/readable-stream/lib/_stream_readable.js:612:20)
  30. at emitOne (events.js:96:13)
  31. at DestroyableTransform.emit (events.js:191:7)
  32. at addChunk (/code/api/node_modules/readable-stream/lib/_stream_readable.js:284:12)
  33. at readableAddChunk (/code/api/node_modules/readable-stream/lib/_stream_readable.js:271:11)
  34. at DestroyableTransform.Readable.push (/code/api/node_modules/readable-stream/lib/_stream_readable.js:238:10)
Add Comment
Please, Sign In to add comment