0

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...

Community
  • 1
  • 1
Karayel
  • 37
  • 1
  • 2
  • 10

1 Answers1

0

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; } }; 
Codesingh
  • 3,316
  • 1
  • 11
  • 18
  • node_modules/cloudinary/lib/utils.js:1028 return callback(void 0, result); TypeError: callback is not a function . I think some issue about the library but I can't figure out. – Karayel Jan 10 '17 at 20:10
  • The full code is in the question. But here is the problem. `v1_result_adapter = function(callback) { if (callback != null) { return function(result) { if (result.error != null) { return callback(result.error); } else { return callback(void 0, result); } }; } else { return null; } };` – Karayel Jan 10 '17 at 20:42
  • it's because you are not passing callback everytime. – Codesingh Jan 10 '17 at 20:51
  • This is not my code. Here is the library. https://github.com/cloudinary/cloudinary_npm/blob/master/lib/utils.js line 1022 – Karayel Jan 10 '17 at 20:53
  • The code you shared: `cloudinary.uploader.upload(videoFile, function(result) {console.log(result); }, { resource_type: "video" });` Should work fine for videos. Are you getting an 'Invalid image file' error when running it? – Roee Ben-Ari Jan 11 '17 at 11:16
  • Nope. Video file json data is coming but I can't pass v1_result_adapter function because of TypeError but I try it again. – Karayel Jan 11 '17 at 11:19
  • Yes, I am getting "Invalid image file" when I use cloudinary.uploader.upload. But when I use cloudinary.uploader.upload_large, v1_result_adapter function taken result as https://jsonblob.com/ba322512-d7f0-11e6-b16a-7d99b2ab453d then TypeError. – Karayel Jan 11 '17 at 11:26
  • 'Invalid image file' error is raised when you try to upload a resource which isn't an image (`resource_type` is defaulted to image). Using `resource_type` should help - set `video` if you want to upload a video file or `raw` for files that are niether video or image. This works perfect on my end, so please check your code again. – Roee Ben-Ari Jan 13 '17 at 06:23
  • Hı, I am setting resource_type as a video, raw, auto and my code is not working."TypeError: callback is not a function" error still continues. Do you have any suggestion to fix it ? – Karayel Jan 20 '17 at 20:51
  • Hı, I solved my problem. Here is the link. (https://github.com/cloudinary/cloudinary_npm/issues/129) – Karayel Jan 21 '17 at 13:12