0
votes

Here is cloudinary documentation page. http://cloudinary.com/documentation/upload_videos#uploading_from_server_side_code

According to doc, video uploading like the following code.

var videoFile = req.files.video.path;    
cloudinary.uploader.upload(videoFile,
                function(result) {console.log(result); },
                { resource_type: "video" });

Also, it supports none image file upload like that.

var videoFile = req.files.video.path;
cloudinary.uploader.upload(videoFile,
                function(result) {console.log(result); },
                { resource_type: "raw" });

Also my html file:

<form action="/videos/add" enctype="multipart/form-data" method="post">
                    <div class="form_line">
                        <label for="video_title">Title:</label>
                        <div class="form_controls">
                            <input id="video_title" name="title" size="30" type="text" />
                        </div>
                    </div>
                    <div class="form_line">
                        <label for="video">Video:</label>
                        <div class="form_controls">
                            <input id="video" name="video" type="file" />
                        </div>
                    </div>
                    <div class="form_line">
                        <div class="form_controls">
                            <button type="submit" class="btn btn-danger">Submit Video</button>
                        </div>
                    </div>
                    <input id="direct" name="direct" type="hidden" />
                </form>

I am getting error for the both code even I specify the resource type.

{"error":{"message":"Invalid image file"}}

https://github.com/cloudinary/cloudinary_npm/issues/26

Upload video to Cloudinary

How can I solve this issue ?

Thanks...

1

1 Answers

0
votes

You can also upload the video in chunks this is very suitable for large files.

cloudinary.uploader.upload_large(file, 
            function(result) {console.log(result); }, 
            { resource_type: "video" });

    v1_result_adapter = function(callback) {
 if (callback != null) {
 return function(result) { if (result.error != null) { 
callback(result.error); return;} else { callback(void 0, result); return; } }; } else { return null; } };