carboneio / tiny-storage-client Goto Github PK
View Code? Open in Web Editor NEWTiny node client to request distributed AWS S3 or the OpenStack Swift Object Storage.
License: Apache License 2.0
Tiny node client to request distributed AWS S3 or the OpenStack Swift Object Storage.
License: Apache License 2.0
Hello,
first of all thanks you for your package because it's the only one that I achieved to make it work in a second for my object cloud OVH
it's not an issue but I don't understand how works downloadFile with stream.
I have a video file on my cloud, I want that my client can read the video in streaming without waiting the whole load of the file before playing it.
as the doc says :
function createOutputStream(opts, res) {
const writer = fs.createWriteStream('5be9a29f97caa8a38e030f0b18ac6fb1.mp4')
writer.on('error', (e) => { console.log("erreur : " + e) })
return writer
}
s3storage.downloadFile('coachtest', '5be9a29f97caa8a38e030f0b18ac6fb1.mp4', { output: createOutputStream }, (err, resp) => {
if (err) {
return console.log("Error on download: ", err);
}
/**
* Request reponse:
* - resp.headers
* - resp.statusCode
*
* When the callback is called, the stream is closed and the file created,
* you don't have to pipe yourself!
*/
})
How do I send the stream to the client ? "When the callback is called, the stream is closed and the file created. You don't have to pipe yourself!" What does that mean ?
I wrote this :
function createOutputStream(opts, res) {
const writer = fs.createWriteStream('5be9a29f97caa8a38e030f0b18ac6fb1.mp4')
writer.on('error', (e) => { console.log("erreur : " + e) })
return writer
}
s3storage.downloadFile('coachtest', '5be9a29f97caa8a38e030f0b18ac6fb1.mp4', { output: createOutputStream }, (err, resp) => {
if (err) {
return console.log("Error on download: ", err);
}
const stream = fs.createReadStream('5be9a29f97caa8a38e030f0b18ac6fb1.mp4');
res.setHeader('Content-Type', 'video/mp4');
stream.pipe(res);
})
but the client wait the whole video to load before receiving it.
How can I make it work ?
Thanks you !
Hi there, I have a problem while executing uploadFiles.
In the connection phase the storage is connecting correctly to my OVH storage, I also can fetch all the objects from my containers. The problem occur when I try to upload some files, it will throw the error in the title plus this 'SWIFT Storage | Object Storages are not available'. I've tried with the path and the buffer but the result is the same.
I also share some code here:
const storage = storageClient({ authUrl:
${process.env.OS_AUTH_URL!}/v3`,
username: process.env.OS_USERNAME!,
password: process.env.OS_PASSWORD!,
region: process.env.OS_REGION_NAME,
});
storage.connection((err: any, connection: any) => {
if (err) {
logError(err);
return;
}
console.log('Connected to Openstack');
});
async function uploadFile2({
containerName,
fileName,
filePath,
oldFileName,
filePrefix
}: {
containerName: string,
fileName: string,
filePath: any,
oldFileName?: string | null,
filePrefix?: string | null
}) {
return new Promise(async (resolve, reject) => {
await storage.listFiles(containerName, (err: any, res: any) => {
if (err) {
logError(err);
return reject(err);
}
console.log(res);
});
const buffer = Buffer.from(fs.readFileSync(path.join(filePath)));
const res = await storage.uploadFile(containerName, fileName, buffer, (err: any, res: any) => {
if (err) {
logError(err);
return reject(err);
}
resolve(res);
});
console.log(res);
});
}
`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.