Code Monkey home page Code Monkey logo

tiny-storage-client's People

Contributors

steevepay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tiny-storage-client's Issues

downloadFile by streaming

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 !

SWIFT Storage | Index "0" region "DE" | Error: TimeoutError

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);
});

}
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.