-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working admin endpoints for object operations
- Loading branch information
TimHuynh
committed
Dec 18, 2024
1 parent
8e9cd8e
commit 3239b53
Showing
9 changed files
with
293 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package minio | ||
|
||
import ( | ||
"context" | ||
api "github.com/go-vela/server/api/types" | ||
"time" | ||
) | ||
|
||
// PresignedGetObject generates a presigned URL for downloading an object. | ||
func (c *MinioClient) PresignedGetObject(ctx context.Context, object *api.Object) (string, error) { | ||
// Generate presigned URL for downloading the object. | ||
// The URL is valid for 7 days. | ||
presignedURL, err := c.client.PresignedGetObject(ctx, object.BucketName, object.ObjectName, 7*24*time.Hour, nil) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return presignedURL.String(), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
package minio | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
api "github.com/go-vela/server/api/types" | ||
"github.com/minio/minio-go/v7" | ||
) | ||
|
||
// Helper methods for uploading objects | ||
func (c *MinioClient) Upload(ctx context.Context, bucketName, objectName string, data []byte, contentType string) error { | ||
c.Logger.Tracef("uploading data to bucket %s", bucketName) | ||
// Upload uploads an object to a bucket in MinIO.ts | ||
func (c *MinioClient) Upload(ctx context.Context, object *api.Object) error { | ||
c.Logger.Tracef("uploading data to bucket %s", object.ObjectName) | ||
|
||
reader := bytes.NewReader(data) | ||
_, err := c.client.PutObject(ctx, bucketName, objectName, reader, int64(len(data)), minio.PutObjectOptions{ContentType: contentType}) | ||
_, err := c.client.FPutObject(ctx, object.BucketName, object.ObjectName, object.FilePath, minio.PutObjectOptions{}) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters