diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2025-11-25 15:34:28 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-25 15:34:28 -0800 |
| commit | c156a130b7e1fbd8b63da3b24b494c9fbeb91d30 (patch) | |
| tree | 9b250e9c2caec47354a9dd02cf01b8d7a983945b /weed/s3api/s3api_object_handlers_multipart.go | |
| parent | 2843cb1255642816dab23562bfa68f98d80aebd1 (diff) | |
| download | seaweedfs-c156a130b7e1fbd8b63da3b24b494c9fbeb91d30.tar.xz seaweedfs-c156a130b7e1fbd8b63da3b24b494c9fbeb91d30.zip | |
S3: Auto create bucket (#7549)
* auto create buckets
* only admin users can auto create buckets
* Update weed/s3api/s3api_bucket_handlers.go
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* validate bucket name
* refactor
* error handling
* error
* refetch
* ensure owner
* multiple errors
---------
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Diffstat (limited to 'weed/s3api/s3api_object_handlers_multipart.go')
| -rw-r--r-- | weed/s3api/s3api_object_handlers_multipart.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/weed/s3api/s3api_object_handlers_multipart.go b/weed/s3api/s3api_object_handlers_multipart.go index ba9886d66..2d9f8e620 100644 --- a/weed/s3api/s3api_object_handlers_multipart.go +++ b/weed/s3api/s3api_object_handlers_multipart.go @@ -33,8 +33,14 @@ const ( func (s3a *S3ApiServer) NewMultipartUploadHandler(w http.ResponseWriter, r *http.Request) { bucket, object := s3_constants.GetBucketAndObject(r) - // Check if bucket exists before creating multipart upload - if err := s3a.checkBucket(r, bucket); err != s3err.ErrNone { + // Check if bucket exists, and create it if it doesn't (auto-create bucket) + if err := s3a.checkBucket(r, bucket); err == s3err.ErrNoSuchBucket { + // Auto-create bucket if it doesn't exist (requires Admin permission) + if !s3a.handleAutoCreateBucket(w, r, bucket, "NewMultipartUploadHandler") { + return + } + } else if err != s3err.ErrNone { + // Other errors (like access denied) should still fail s3err.WriteErrorResponse(w, r, err) return } |
