Upload image to specified folder node js with cloudinary.v2
How to upload image to specify folder with nodejs and cloudinary.v2? Currently my code is only upload and stores it in asset and its messy.
'data.pict' is the image to upload
-
Hi Rizky,
The first parameter of the `upload()` method in the SDK is the file to upload (the 'file' parameter sent to the API endpoint) and any other options specified should be set in an options array, passed as the second parameter to the API call
To set the folder path, you can do this by specifying the public_id value directly and including the folder path there, or by passing the 'folder' parameter, which will set a folder path (and then use whichever method of naming the file was specified or implied by the other upload options)
There's more information here in the Upload documentation, and as with many of the cod examples you can click a tab to see a specific Node example: https://cloudinary.com/documentation/upload_images#using_the_public_id_to_organize_media_assets_in_foldersFor your example code, a minimally-changed example would be:
cloudinary.uploader
.upload(data.pict, {folder: 'myfolder'})
.then....May I ask you to please try that and let me know if it works?
Regards
Stephen4 -
Thanks, Stephen it works for me.
0 -
thanks, Stephen it also work for me
0
Post is closed for comments.
Comments
3 comments