To get images from an API and save them to B2 cloud storage in TypeScript, you will need to do the following:
node-fetch
to fetch the image from the API and fs-extra
to write the file to disk and upload it to B2 cloud storage.index.ts32 chars2 lines
node-fetch
. The response will be a Buffer
object containing the binary image data.index.ts139 chars5 lines
fs-extra
.index.ts82 chars4 lines
index.ts681 chars25 lines
This should upload the file to your B2 cloud storage bucket. You can also add more options to the uploadFile
method, such as setting custom metadata or file retention settings. Check the backblaze-b2
documentation for more information.
gistlibby LogSnag