GithubHelp home page GithubHelp logo

Comments (5)

ug0 avatar ug0 commented on August 15, 2024 1

I'll try to get this done by today or tomorrow.

from aliyun_oss.

ug0 avatar ug0 commented on August 15, 2024

Oh, I didn't think of the that when I wrote the object_url fucntion. Actually I just wanted a convenient way to expose the object URL for downloading.

I think we can add a new function signed_url(or if you have a better name) to support all the features described in the official doc.

def signed_url(bucket, object, expires, method \\ "GET", headers \\ ${}, sub_resources \\ %{}) do
end

What do you think?

from aliyun_oss.

vip30 avatar vip30 commented on August 15, 2024

LGTM

Will you commit this changes?

Thanks

from aliyun_oss.

ug0 avatar ug0 commented on August 15, 2024

This has been implemented and merged to master. While I was coding, I realized maybe I shouldn't limit signed_url to only objects. But I don't want to just define another Bucket.signed_url function because I think that's a bit redundant and there should be a better way.
Eventually I decide to just release a new version with Object.signed_url for now.

However, if you look at the implementation of Object.signed_url, you can easilly build any signed URL for other APIs by using Request.signed_query_url. For example:

  # Signed URL for GetBucket
   %{
      verb: "GET",
      host: "#{bucket}.#{endpoint()}",
      path: "/",
      resource: "/#{bucket}/",
      sub_resources: %{},
      headers: %{"Content-Type" => ""},
      expires: expires
    }
    |> Request.build()
    |> Request.signed_query_url()
  # Signed URL for PutBucketAcl
   %{
      verb: "PUT",
      host: "#{bucket}.#{endpoint()}",
      path: "/",
      resource: "/#{bucket}/",
      sub_resources: %{"acl" => nil},
      headers: %{"Content-Type" => "text/plain;charset=UTF-8", "x-oss-acl" => "private"},
      expires: expires
    }
    |> Request.build()
    |> Request.signed_query_url()
  # Signed URL for GetBucket
   %{
      verb: "GET",
      host: endpoint(),
      path: "/",
      resource: "/",
      sub_resources: %{"Content-Type" => ""},
      headers: %{},
      expires: expires
    }
    |> Request.build()
    |> Request.signed_query_url()

from aliyun_oss.

ug0 avatar ug0 commented on August 15, 2024

v0.5.0 has been released.

from aliyun_oss.

Related Issues (5)

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.