> If it's an object that already exists

no, sadly it's not, i need to generate the url to which i can upload the
image to, that url should be unsigned not signed.
that being said, a signed url might be fine.

On Thu, Dec 24, 2020 at 2:31 PM David Finkel <david.fin...@gmail.com> wrote:

>
>
> On Mon, Dec 21, 2020 at 5:54 PM Alexander Mills <
> alexander.d.mi...@gmail.com> wrote:
>
>> this is a little irritating lol, i can get a signed url via:
>>
>> bucket := "bnk-photos"
>> filename := "mypic3.json"
>> method := "PUT"
>> expires := time.Now().Add(time.Minute * 10)
>>
>> url, err := storage.SignedURL(bucket, filename, &storage.SignedURLOptions{
>> GoogleAccessID: cfg.Email,
>> PrivateKey: cfg.PrivateKey,
>> Method: method,
>> Expires: expires,
>> ContentType: "binary/octet-stream",
>> })
>>
>>
>> but I just want an *unsigned* url?
>> how?
>>
>
> If it's an object that already exists that you want to provide access to
> the current version, you want: ObjectAttrs.MediaLink
> <https://pkg.go.dev/cloud.google.com/go/storage#ObjectAttrs.MediaLink>,
> so you'd do something like:
>
> gcsClient, clientErr := storage.NewClient(ctx)
> // if clientErr != nil {....
> obj := gcsClient.Bucket(bucket).Object(filename)
> objattr, attrErr := obj.Attrs(ctx)
> // if attrErr != nil { ...
> fmt.Println(objattr.MediaLink) // this
>
> On the other hand, your example uses the PUT method for signing the URL,
> in which case I think you'd need to construct the URL directly as either
> XML (S3-compatible)
> <https://cloud.google.com/storage/docs/xml-api/get-object-download#request_syntax>
> :
> fmt.Sprintf("%s.storage.googleapis.com/%s", bucket, filename)
>
> or JSON (GCS)
> <https://cloud.google.com/storage/docs/json_api/v1/objects/get#http-request>
> :
> fmt.Sprintf("https://storage.googleapis.com/storage/v1/b/%s/o/%s";,
> bucket, filename)
>>
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/golang-nuts/f00bd659-dbed-4161-8b6c-456f41ccbb22n%40googlegroups.com
>> <https://groups.google.com/d/msgid/golang-nuts/f00bd659-dbed-4161-8b6c-456f41ccbb22n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
Alexander D. Mills
New cell phone # (415)730-1805
linkedin.com/in/alexanderdmills

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CA%2BKyZp7Kq32Tw2aPTrCXzX8rKwMUnkqO%2BAZStnXeurDamNrC_w%40mail.gmail.com.

Reply via email to