Giter VIP home page Giter VIP logo

Comments (8)

nadavs avatar nadavs commented on September 17, 2024 3

In order to upload non-image files as raw files, you need to set the resource_type parameter to raw.

See: http://cloudinary.com/documentation/node_image_upload#raw_file_uploading

from cloudinary_npm.

souli2020 avatar souli2020 commented on September 17, 2024 2

Hi @wissam-khalili!
Yes because it's an old comment I wanted to add some recent solution! Hopefully someone will find it helpful;
Thank you

from cloudinary_npm.

souli2020 avatar souli2020 commented on September 17, 2024 1

For anyone recently facing this issue and researches for a solution and came across this comments you can use this :

 cloudinary: cloudinary,
    params: async (req, file) => {
        let resource_type = 'auto';
        if (file.mimetype.startsWith('image/')) {
            resource_type = 'image';
        } else if (file.mimetype.startsWith('video/')) {
            resource_type = 'video';
        }
        return {
            folder: 'folder',
            allowed_formats: ['jpeg', 'jpg', 'png', 'mp4',.....],
            public_id: `${Date.now()}-${file.originalname}`,
            resource_type: resource_type,
        };
    },

from cloudinary_npm.

wissam-khalili avatar wissam-khalili commented on September 17, 2024 1

Hi @souli2020 ,

Thank you for sharing your input.
This was a very old comment since 2014 - lots of things have changed.
Thanks again,
Wissam

from cloudinary_npm.

shivanshu-2002 avatar shivanshu-2002 commented on September 17, 2024 1

Try ..to use cloudinary.v2...const uploadFileToCloudinary = async (file, folder) => {
const options = { folder };
options.resource_type="auto";
try {
const response = await cloudinary.v2.uploader.upload(file.tempFilePath, options);
return response;
} catch (error) {
console.error('Error uploading to Cloudinary:', error);
throw error; // Re-throw the error to handle it in the calling function
}
}

from cloudinary_npm.

callmekatootie avatar callmekatootie commented on September 17, 2024

FYI I was attempting to upload .mkv and .mp4 files

from cloudinary_npm.

callmekatootie avatar callmekatootie commented on September 17, 2024

Thank You!

from cloudinary_npm.

dannyv-cloudinary avatar dannyv-cloudinary commented on September 17, 2024

Hey @shivanshu-2002.

The best thing to do here would be to raise a support ticket with us, including your cloud name and the error message you get in response when you run that code snippet.

All the best,
-Danny

from cloudinary_npm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.