Skip to content

Commit 9e761f9

Browse files
authored
feat(storage): post support dynamic key name (#12677)
* feat(storage): post support dynamic key name * review updates
1 parent 8650d33 commit 9e761f9

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

storage/bucket.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ func (b *BucketHandle) SignedURL(object string, opts *SignedURLOptions) (string,
225225
// to be non-nil. You may need to set the GoogleAccessID and PrivateKey fields
226226
// in some cases. Read more on the [automatic detection of credentials] for this method.
227227
//
228+
// To allow the unauthenticated client to upload to any object name in the
229+
// bucket with a given prefix rather than a specific object name, you can pass
230+
// an empty string for object and set [PostPolicyV4Options].Conditions to
231+
// include [ConditionStartsWith]("$key", "prefix").
232+
//
228233
// [automatic detection of credentials]: https://pkg.go.dev/cloud.google.com/go/storage#hdr-Credential_requirements_for_signing
229234
func (b *BucketHandle) GenerateSignedPostPolicyV4(object string, opts *PostPolicyV4Options) (*PostPolicyV4, error) {
230235
// Make a copy of opts so we don't modify the pointer parameter.

storage/post_policy_v4.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,6 @@ func GenerateSignedPostPolicyV4(bucket, object string, opts *PostPolicyV4Options
252252
if bucket == "" {
253253
return nil, errors.New("storage: bucket must be non-empty")
254254
}
255-
if object == "" {
256-
return nil, errors.New("storage: object must be non-empty")
257-
}
258255
now := utcNow()
259256
if err := validatePostPolicyV4Options(opts, now); err != nil {
260257
return nil, err

0 commit comments

Comments
 (0)