FAQ
Hello,

I'm trying to port a tool of mine to use Google Cloud Storage (it presently
only works with S3) and have been using the client API from
https://github.com/google/google-api-go-client .

However, while the underlying GCS API provides the functionality that I
need via http headers (Specifically I need "Range" and "IfMatch" on getting
object content (re: https://cloud.google.com/storage/docs/reference-headers
)) it appears to be omitted from the go client API and I don't see a way to
specify those fields without changing the library.

It looks like the most consistent way would be to mirror how IfNotMatch was
implemented, which means adding a code to update the headers in:
  func (c *ObjectsGetCall) doRequest(alt string) (*http.Response, error)

Is there in fact a way to add headers to the request that I'm missing?
  Or should I submit an upstream change to add this? (I noticed the
CONTRIBUTING.md has instructions for pushing upstream, but it looks like
it'll take chunk of time to read through and do it properly.)

Thanks,
Phil

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Nick Craig-Wood at Nov 23, 2015 at 12:41 pm

    On 22/11/15 16:38, pmontgom@broadinstitute.org wrote:
    I'm trying to port a tool of mine to use Google Cloud Storage (it
    presently only works with S3) and have been using the client API from
    https://github.com/google/google-api-go-client .
    I've used this library.
    However, while the underlying GCS API provides the functionality that I
    need via http headers (Specifically I need "Range" and "IfMatch" on
    getting object content (re:
    https://cloud.google.com/storage/docs/reference-headers )) it appears to
    be omitted from the go client API and I don't see a way to specify those
    fields without changing the library.
    From what I remember the GCS API only provides a URL to download the
    content.

    You are then on your own to download the actual content from that URL
    with your own http.Client. You can set as many headers on that request
    as you like, including "Range" and "IfMatch" I'm sure.

    Here is an example I wrote (some time ago) of actually downloading a
    file from GCS

    https://github.com/ncw/rclone/blob/master/googlecloudstorage/googlecloudstorage.go#L582


    --
    Nick Craig-Wood <nick@craig-wood.com> -- http://www.craig-wood.com/nick

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Philip Montgomery at Nov 23, 2015 at 4:58 pm
    Ah, thanks that's a good point. I suppose I could always handle the
    retrieval of the content on my own outside of the client library.

    I'll just mention as a fyi (and partially because it took me a long time to
    find it, and may be helpful for someone else), it looks like they added the
    ability to download the content as well back in January. ( Do() retrieves
    the metadata, but Download() retrieves the file content. re:
    https://github.com/google/google-api-go-client/commit/0a735f7ec81c85ce7ec31bf7a67e125ef62266ec
      )

    Thanks
    On Mon, Nov 23, 2015 at 7:41 AM, Nick Craig-Wood wrote:
    On 22/11/15 16:38, pmontgom@broadinstitute.org wrote:
    I'm trying to port a tool of mine to use Google Cloud Storage (it
    presently only works with S3) and have been using the client API from
    https://github.com/google/google-api-go-client .
    I've used this library.
    However, while the underlying GCS API provides the functionality that I
    need via http headers (Specifically I need "Range" and "IfMatch" on
    getting object content (re:
    https://cloud.google.com/storage/docs/reference-headers )) it appears to
    be omitted from the go client API and I don't see a way to specify those
    fields without changing the library.
    From what I remember the GCS API only provides a URL to download the
    content.

    You are then on your own to download the actual content from that URL
    with your own http.Client. You can set as many headers on that request
    as you like, including "Range" and "IfMatch" I'm sure.

    Here is an example I wrote (some time ago) of actually downloading a
    file from GCS


    https://github.com/ncw/rclone/blob/master/googlecloudstorage/googlecloudstorage.go#L582


    --
    Nick Craig-Wood <nick@craig-wood.com> -- http://www.craig-wood.com/nick
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 23, '15 at 4:00a
activeNov 23, '15 at 4:58p
posts3
users2
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase