MCPcopy
hub / github.com/minio/minio-go / presignURL

Method presignURL

api-presigned.go:33–63  ·  view source on GitHub ↗

presignURL - Returns a presigned URL for an input 'method'. Expires maximum is 7days - ie. 604800 and minimum is 1.

(ctx context.Context, method, bucketName, objectName string, expires time.Duration, reqParams url.Values, extraHeaders http.Header)

Source from the content-addressed store, hash-verified

31// presignURL - Returns a presigned URL for an input 'method'.
32// Expires maximum is 7days - ie. 604800 and minimum is 1.
33func (c *Client) presignURL(ctx context.Context, method, bucketName, objectName string, expires time.Duration, reqParams url.Values, extraHeaders http.Header) (u *url.URL, err error) {
34 // Input validation.
35 if method == "" {
36 return nil, errInvalidArgument("method cannot be empty.")
37 }
38 if err = s3utils.CheckValidBucketName(bucketName); err != nil {
39 return nil, err
40 }
41 if err = isValidExpiry(expires); err != nil {
42 return nil, err
43 }
44
45 // Convert expires into seconds.
46 expireSeconds := int64(expires / time.Second)
47 reqMetadata := requestMetadata{
48 presignURL: true,
49 bucketName: bucketName,
50 objectName: objectName,
51 expires: expireSeconds,
52 queryValues: reqParams,
53 extraPresignHeader: extraHeaders,
54 }
55
56 // Instantiate a new request.
57 // Since expires is set newRequest will presign the request.
58 var req *http.Request
59 if req, err = c.newRequest(ctx, method, reqMetadata); err != nil {
60 return nil, err
61 }
62 return req.URL, nil
63}
64
65// PresignedGetObject - Returns a presigned URL to access an object
66// data without credentials. URL can have a maximum expiry of

Callers 5

PresignedGetObjectMethod · 0.95
PresignedHeadObjectMethod · 0.95
PresignedPutObjectMethod · 0.95
PresignHeaderMethod · 0.95
PresignMethod · 0.95

Calls 4

newRequestMethod · 0.95
CheckValidBucketNameFunction · 0.92
errInvalidArgumentFunction · 0.85
isValidExpiryFunction · 0.85

Tested by

no test coverage detected