totaljs / framework

Node.js framework
http://www.totaljs.com
Other
4.36k stars 450 forks source link

total.js way to upload audio, video, other files formats in server file system ? #667

Closed trendchaser4u closed 6 years ago

trendchaser4u commented 6 years ago

This is not actually an issue. Kind of suggestion to a proper way of implementing upload files (different formats) to the server.

Using total.js 3.0.0

Note: In documentation, I could only find a way to save(upload) images with image.save() method.

petersirka commented 6 years ago

Hi, it's same but images can be processed ImageMagick or GraphicsMagick --> image.save(). Uploading is very easy https://github.com/totaljs/examples/tree/master/upload-multipart

trendchaser4u commented 6 years ago

yeah but it save files in tmp dir :( i need to upload to public dir.

petersirka commented 6 years ago

Files are saved in tmp, but they are removed after you close a controller. You can use: https://docs.totaljs.com/latest/en.html#api~HttpFile~file.move

function some_upload_action() {
    var self = this;
    self.files[0].move(F.path.public('myfile.jpg'), function() {
        self.json({ success: true });
    });
}
trendchaser4u commented 6 years ago

yup !! got it... thanks a lot!! you are awesome :) :+1: