Comments (8)
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.
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.
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.
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.
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.
FYI I was attempting to upload .mkv and .mp4 files
from cloudinary_npm.
Thank You!
from cloudinary_npm.
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)
- Missing`upload_stream` documentation HOT 6
- Escaping overlay text seems impossible in the version 1.41.0 HOT 8
- Unexpected token < in JSON at position 0. Status code 500 in Nextjs 13 production build (App router) HOT 9
- Support passing in analytics product version to URL generation HOT 2
- Typescript error on search API HOT 2
- Invalid signature String to sign HOT 2
- Cloudinary.com Signup Process HOT 3
- Missing return types on v2.api.resources() HOT 4
- Uploading file as buffer does not works in production. HOT 17
- "Error: must supply api_key" in heroku log HOT 3
- mp3 file is not being deleted HOT 1
- TypeScript error: `Property 'end' does not exist on type 'UploadStream'.` HOT 1
- Must supply api_key HOT 1
- Photo Query Page updates dynamically in local machine, but failed to update dynamically after deployment to Cloudflare or Netlify HOT 1
- error fetching photos by folder HOT 3
- TypeError: Cannot read properties of undefined (reading 'secure_url') When i uploading image to cloudinary as const response = await uploadFileToCloudinary(file, "Mayank"); console.log(response); Then the response is printed as undefined and the error is provided HOT 4
- TypeError: Cannot read properties of undefined (reading 'secure_url') When i uploading image to cloudinary as const response = await uploadFileToCloudinary(file, "Mayank"); console.log(response); Then the response is printed as undefined and the error is provided HOT 1
- Missing download_folder method in typescript types HOT 2
- Bán acc xamvn - xamvn.casa xamvn.vl , acc xamvn giá siêu rẻ
- Unable to delete raw file HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloudinary_npm.