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> > . > -- 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/CANrC0BgayVQagGkDXzL8kZeH1UZrMa_8nYy3FVss1smuSu7_MQ%40mail.gmail.com.