I need set a limit for upload speed for a script that uploads videos to a S3 (MiniO). I tried with 'speed-limiter' and 'bandwidth-throttle-stream' and doesn't work.
I want to limit the upload speed to 8MB/s
(This is my first node.js script)
const chokidar = require('chokidar')
const notifier = require('node-notifier')
const Minio = require('minio')
const minio = new Minio.Client({
endPoint: '${dns-example}',
port: 9000,
useSSL: false,
accessKey: '${user-example}',
secretKey: '${pass-example}'
})
const metaData = {
'Content-Type': 'application/octet-stream',
'X-Amz-Meta-Testing': 1234,
'example': 5678
}
chokidar.watch('/Users/glichester/Movies', {ignoreInitial: true}).on('add', path => {
notifier.notify({
title: 'New clip saved',
message: `Clip: ${path.slice(24)}`,
icon: 'icon.png',
sound: true,
appID: "Clip saver"
})
chokidar.watch(path).on('change', file => minio.fPutObject('glichester', path.slice(24), path, metaData, err => {
notifier.notify({
title: `Clip uploaded ${err == null ? "correctly" : "fail"}`,
message: `It's ${err == null ? "uploaded" : "tried to upload"} to the cloud ${path.slice(24)}... ERROR: ${err}`,
icon: 'icon.png',
sound: true,
appID: "Clip saver"
})
}))
})
This script works.