通过nextjs api文件夹向nodejs api发送图像

acruukt9  于 2021-09-13  发布在  Java
关注(0)|答案(1)|浏览(417)

我有一个文件示例,是我从强大的图书馆得到的。看起来像这样

  1. photo: File {
  2. _events: [Object: null prototype] {},
  3. _eventsCount: 0,
  4. _maxListeners: undefined,
  5. size: 16648,
  6. path: 'public/upload_1.jpg',
  7. name: 'test.jpg',
  8. type: 'image/jpeg',
  9. hash: null,
  10. lastModifiedDate: 2021-07-08T11:22:05.804Z,
  11. _writeStream: WriteStream {
  12. _writableState: [WritableState],
  13. writable: false,
  14. _events: [Object: null prototype] {},
  15. _eventsCount: 0,
  16. _maxListeners: undefined,
  17. path: 'public/upload_1.jpg',
  18. fd: null,
  19. flags: 'w',
  20. mode: 438,
  21. start: undefined,
  22. autoClose: true,
  23. pos: undefined,
  24. bytesWritten: 16648,
  25. closed: false
  26. }
  27. }

现在,我需要将此图像传递给一个外部nodejs api,该api希望该图像在

  1. req.file('photo')

格式。
请帮助如何将上述示例发送到nodejsapi。
提前谢谢

hjqgdpho

hjqgdpho1#

serverside formdata和fs.createreadstream对我来说非常有吸引力。

相关问题