Upload image to specified folder node js with cloudinary.v2

Comments

1 comment

  • Avatar
    Stephen Doyle

    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_folders

    For 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
    Stephen

    0
    Comment actions Permalink

Please sign in to leave a comment.