Maximum is 10485760 upload video with Apollo server and upload_stream
How can I upload video with
cloudinary.uploader.upload_stream
******************
cloudinary.v2.uploader.upload_large (archivo, { resource_type : " video " }, función (error, resultado) {console.log (resultado, error); });
**********
createReadStream().pipe(
cloudinary.uploader.upload_stream.upload_large((error, result)
*********
async createPost(_, { body, file }, context) {
const user = checkAuth(context);
const { filename, createReadStream } = await file;
if (body.trim() === '') {
throw new Error('Post body must not be empty');
}
const result = await new Promise((resolve, reject) => {
createReadStream().pipe(
cloudinary.uploader.upload_stream((error, result) => {
if (error) {
reject(error);
}
resolve(result);
})
);
console.log("createReadStream: ", createReadStream);
});
const newFile = {
filename,
path: result.secure_url,
type: result.resource_type
};
const newPost = new Post({
body: body,
linkFile: newFile.path,
typeFile: newFile.type,
user: user._id,
username: user.username,
createdAt: new Date().toISOString()
});
//console.log(newPost);
const post = await newPost.save();
context.pubsub.publish('NEW_POST', {
newPost: post
});
return post;
},
0
-
Hi Emerson,
Based on the error message it looks like you're hitting the default image filesize limit. That looks to be the case since your resource_type is set to " video ". Notice the extra whitespace. The SDK would therefore not recognize it as a valid resource_type (image/video/raw) and therefore defaults to image.
May I please ask you to set resource_type to "video" without the whitespace and let me know how it goes.
0
Post is closed for comments.
Comments
1 comment