Closed V-Jgenti closed 2 years ago
In my case the problem is that I was using the relative path of the file that I wanted to publish. You have to use the path of your operating system to the file, and make sure that your directories do not have a blank space in the name.
let file_name = path.resolve(
./uploads/${req.body.files[0]});
Relative: './uploads/ ...'
With path.resolve(./uplodas .. ..): /home/user/uploads/ .. .. . .
This looks like a pathing issue on the file directory or a different error in starting your server, it isn't related to the API.
Getting the error error: connect ECONNREFUSED 127.0.0.1:80 when trying to upload video everithing is configigured by Official documentation step by step i think it's problem with api please check it
`export class VimeoService { public client; constructor() { this.client = new Vimeo( process.env.VIMEO_ID, process.env.VIMEO_SECRET, process.env.VIMEO_TOKEN, ); }
deleteFileFromDir(filePath: string) { fs.unlinkSync(filePath); }
async uploadVideo(videoData: FileDataInterface): Promise {
const { originalname, buffer } = videoData;
const filePath: string = path.resolve(
__dirname,
../../tmp/${originalname}
, ); const writer = fs.createWriteStream(filePath); writer.write(buffer); return new Promise(async (res, rej) => { await this.client.upload( filePath, { name: originalname, }, uri => { const url: string =https://vimeo.com${uri}
.replace('videos/', ''); res(url); }, (bytesUploaded, bytesTotal) => { const percentage: string = ( (bytesUploaded / bytesTotal) * 100 ).toFixed(2); console.log(bytesUploaded, bytesTotal, percentage + '%'); if (parseInt(percentage, 10) === 100) { this.deleteFileFromDir(filePath); } }, error => { rej(error); }, ); }); } }`