Coder Social home page Coder Social logo

Comments (9)

WizTeam avatar WizTeam commented on July 22, 2024 1

S3的使用方法:

      let params = {
        Bucket: self.bucket,
        Key: name,
      };
      //
      let req = self.client.getObject(params);
      let stream = req.createReadStream();

注意stream是返回值,而不是我自己创建的filestream。这样我可以直接把这个stream作为koa的body返回。

from cos-nodejs-sdk-v5.

carsonxu avatar carsonxu commented on July 22, 2024

下载支持 stream 的:

getObject({
    ....,
    Output: fs.createWriteStream('./a.zip');
});

from cos-nodejs-sdk-v5.

WizTeam avatar WizTeam commented on July 22, 2024

这个不行的,只是支持传递一个stream进去。我们更希望的是这个方法返回一个stream。举个例子:

当用户请求下载一个对象的时候,按照当前的方式,我需要创建一个临时文件,然后生成一个writeable stream并传递给cos,在cos下载完成前,我没办法把这个stream返回给客户。

oss,s3的做法是,我请求api,直接给我返回一个readable stream(这时候对象可能还没有开始下载,至少没有下载完成)。然后我可以直接把这个stream作为koa的body返回给客户,用户就可以下载了。

from cos-nodejs-sdk-v5.

carsonxu avatar carsonxu commented on July 22, 2024

s3 是什么格式?

from cos-nodejs-sdk-v5.

dimkua avatar dimkua commented on July 22, 2024

同求,可以pipe给response

from cos-nodejs-sdk-v5.

borie88 avatar borie88 commented on July 22, 2024

+1

from cos-nodejs-sdk-v5.

carsonxu avatar carsonxu commented on July 22, 2024

近期补充支持

from cos-nodejs-sdk-v5.

duanyuanping avatar duanyuanping commented on July 22, 2024

请问这个功能现在支持了吗

from cos-nodejs-sdk-v5.

carsonxu avatar carsonxu commented on July 22, 2024

已支持 cos.getObjectStream(opt).pipe(writeStream)

from cos-nodejs-sdk-v5.

Related Issues (20)

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.