repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1 value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
minio/minio-go | api-stat.go | StatObject | func (c Client) StatObject(bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error) {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return ObjectInfo{}, err
}
if err := s3utils.CheckValidObjectName(objectName); err != nil {
return ObjectInfo{}, err
}
return c.statObject(context.Background(), bucketName, objectName, opts)
} | go | func (c Client) StatObject(bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error) {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return ObjectInfo{}, err
}
if err := s3utils.CheckValidObjectName(objectName); err != nil {
return ObjectInfo{}, err
}
return c.statObject(context.Background(), bucketName, objectName, opts)
} | [
"func",
"(",
"c",
"Client",
")",
"StatObject",
"(",
"bucketName",
",",
"objectName",
"string",
",",
"opts",
"StatObjectOptions",
")",
"(",
"ObjectInfo",
",",
"error",
")",
"{",
"// Input validation.",
"if",
"err",
":=",
"s3utils",
".",
"CheckValidBucketName",
... | // StatObject verifies if object exists and you have permission to access. | [
"StatObject",
"verifies",
"if",
"object",
"exists",
"and",
"you",
"have",
"permission",
"to",
"access",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-stat.go#L93-L102 | train |
minio/minio-go | api-stat.go | statObject | func (c Client) statObject(ctx context.Context, bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error) {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return ObjectInfo{}, err
}
if err := s3utils.CheckValidObjectName(objectName); err != nil {
return ObjectInfo{}, err
}
// Execute HEAD on objectName.
resp, err := c.executeMethod(ctx, "HEAD", requestMetadata{
bucketName: bucketName,
objectName: objectName,
contentSHA256Hex: emptySHA256Hex,
customHeader: opts.Header(),
})
defer closeResponse(resp)
if err != nil {
return ObjectInfo{}, err
}
if resp != nil {
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusPartialContent {
return ObjectInfo{}, httpRespToErrorResponse(resp, bucketName, objectName)
}
}
// Trim off the odd double quotes from ETag in the beginning and end.
md5sum := strings.TrimPrefix(resp.Header.Get("ETag"), "\"")
md5sum = strings.TrimSuffix(md5sum, "\"")
// Parse content length is exists
var size int64 = -1
contentLengthStr := resp.Header.Get("Content-Length")
if contentLengthStr != "" {
size, err = strconv.ParseInt(contentLengthStr, 10, 64)
if err != nil {
// Content-Length is not valid
return ObjectInfo{}, ErrorResponse{
Code: "InternalError",
Message: "Content-Length is invalid. " + reportIssue,
BucketName: bucketName,
Key: objectName,
RequestID: resp.Header.Get("x-amz-request-id"),
HostID: resp.Header.Get("x-amz-id-2"),
Region: resp.Header.Get("x-amz-bucket-region"),
}
}
}
// Parse Last-Modified has http time format.
date, err := time.Parse(http.TimeFormat, resp.Header.Get("Last-Modified"))
if err != nil {
return ObjectInfo{}, ErrorResponse{
Code: "InternalError",
Message: "Last-Modified time format is invalid. " + reportIssue,
BucketName: bucketName,
Key: objectName,
RequestID: resp.Header.Get("x-amz-request-id"),
HostID: resp.Header.Get("x-amz-id-2"),
Region: resp.Header.Get("x-amz-bucket-region"),
}
}
// Fetch content type if any present.
contentType := strings.TrimSpace(resp.Header.Get("Content-Type"))
if contentType == "" {
contentType = "application/octet-stream"
}
expiryStr := resp.Header.Get("Expires")
var expTime time.Time
if t, err := time.Parse(http.TimeFormat, expiryStr); err == nil {
expTime = t.UTC()
}
// Save object metadata info.
return ObjectInfo{
ETag: md5sum,
Key: objectName,
Size: size,
LastModified: date,
ContentType: contentType,
Expires: expTime,
// Extract only the relevant header keys describing the object.
// following function filters out a list of standard set of keys
// which are not part of object metadata.
Metadata: extractObjMetadata(resp.Header),
}, nil
} | go | func (c Client) statObject(ctx context.Context, bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error) {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return ObjectInfo{}, err
}
if err := s3utils.CheckValidObjectName(objectName); err != nil {
return ObjectInfo{}, err
}
// Execute HEAD on objectName.
resp, err := c.executeMethod(ctx, "HEAD", requestMetadata{
bucketName: bucketName,
objectName: objectName,
contentSHA256Hex: emptySHA256Hex,
customHeader: opts.Header(),
})
defer closeResponse(resp)
if err != nil {
return ObjectInfo{}, err
}
if resp != nil {
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusPartialContent {
return ObjectInfo{}, httpRespToErrorResponse(resp, bucketName, objectName)
}
}
// Trim off the odd double quotes from ETag in the beginning and end.
md5sum := strings.TrimPrefix(resp.Header.Get("ETag"), "\"")
md5sum = strings.TrimSuffix(md5sum, "\"")
// Parse content length is exists
var size int64 = -1
contentLengthStr := resp.Header.Get("Content-Length")
if contentLengthStr != "" {
size, err = strconv.ParseInt(contentLengthStr, 10, 64)
if err != nil {
// Content-Length is not valid
return ObjectInfo{}, ErrorResponse{
Code: "InternalError",
Message: "Content-Length is invalid. " + reportIssue,
BucketName: bucketName,
Key: objectName,
RequestID: resp.Header.Get("x-amz-request-id"),
HostID: resp.Header.Get("x-amz-id-2"),
Region: resp.Header.Get("x-amz-bucket-region"),
}
}
}
// Parse Last-Modified has http time format.
date, err := time.Parse(http.TimeFormat, resp.Header.Get("Last-Modified"))
if err != nil {
return ObjectInfo{}, ErrorResponse{
Code: "InternalError",
Message: "Last-Modified time format is invalid. " + reportIssue,
BucketName: bucketName,
Key: objectName,
RequestID: resp.Header.Get("x-amz-request-id"),
HostID: resp.Header.Get("x-amz-id-2"),
Region: resp.Header.Get("x-amz-bucket-region"),
}
}
// Fetch content type if any present.
contentType := strings.TrimSpace(resp.Header.Get("Content-Type"))
if contentType == "" {
contentType = "application/octet-stream"
}
expiryStr := resp.Header.Get("Expires")
var expTime time.Time
if t, err := time.Parse(http.TimeFormat, expiryStr); err == nil {
expTime = t.UTC()
}
// Save object metadata info.
return ObjectInfo{
ETag: md5sum,
Key: objectName,
Size: size,
LastModified: date,
ContentType: contentType,
Expires: expTime,
// Extract only the relevant header keys describing the object.
// following function filters out a list of standard set of keys
// which are not part of object metadata.
Metadata: extractObjMetadata(resp.Header),
}, nil
} | [
"func",
"(",
"c",
"Client",
")",
"statObject",
"(",
"ctx",
"context",
".",
"Context",
",",
"bucketName",
",",
"objectName",
"string",
",",
"opts",
"StatObjectOptions",
")",
"(",
"ObjectInfo",
",",
"error",
")",
"{",
"// Input validation.",
"if",
"err",
":=",... | // Lower level API for statObject supporting pre-conditions and range headers. | [
"Lower",
"level",
"API",
"for",
"statObject",
"supporting",
"pre",
"-",
"conditions",
"and",
"range",
"headers",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-stat.go#L105-L192 | train |
minio/minio-go | api-get-options.go | Header | func (o GetObjectOptions) Header() http.Header {
headers := make(http.Header, len(o.headers))
for k, v := range o.headers {
headers.Set(k, v)
}
if o.ServerSideEncryption != nil && o.ServerSideEncryption.Type() == encrypt.SSEC {
o.ServerSideEncryption.Marshal(headers)
}
return headers
} | go | func (o GetObjectOptions) Header() http.Header {
headers := make(http.Header, len(o.headers))
for k, v := range o.headers {
headers.Set(k, v)
}
if o.ServerSideEncryption != nil && o.ServerSideEncryption.Type() == encrypt.SSEC {
o.ServerSideEncryption.Marshal(headers)
}
return headers
} | [
"func",
"(",
"o",
"GetObjectOptions",
")",
"Header",
"(",
")",
"http",
".",
"Header",
"{",
"headers",
":=",
"make",
"(",
"http",
".",
"Header",
",",
"len",
"(",
"o",
".",
"headers",
")",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"o",
".",
... | // Header returns the http.Header representation of the GET options. | [
"Header",
"returns",
"the",
"http",
".",
"Header",
"representation",
"of",
"the",
"GET",
"options",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-get-options.go#L42-L51 | train |
minio/minio-go | api-get-options.go | Set | func (o *GetObjectOptions) Set(key, value string) {
if o.headers == nil {
o.headers = make(map[string]string)
}
o.headers[http.CanonicalHeaderKey(key)] = value
} | go | func (o *GetObjectOptions) Set(key, value string) {
if o.headers == nil {
o.headers = make(map[string]string)
}
o.headers[http.CanonicalHeaderKey(key)] = value
} | [
"func",
"(",
"o",
"*",
"GetObjectOptions",
")",
"Set",
"(",
"key",
",",
"value",
"string",
")",
"{",
"if",
"o",
".",
"headers",
"==",
"nil",
"{",
"o",
".",
"headers",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"}",
"\n",
... | // Set adds a key value pair to the options. The
// key-value pair will be part of the HTTP GET request
// headers. | [
"Set",
"adds",
"a",
"key",
"value",
"pair",
"to",
"the",
"options",
".",
"The",
"key",
"-",
"value",
"pair",
"will",
"be",
"part",
"of",
"the",
"HTTP",
"GET",
"request",
"headers",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-get-options.go#L56-L61 | train |
minio/minio-go | api-get-options.go | SetMatchETag | func (o *GetObjectOptions) SetMatchETag(etag string) error {
if etag == "" {
return ErrInvalidArgument("ETag cannot be empty.")
}
o.Set("If-Match", "\""+etag+"\"")
return nil
} | go | func (o *GetObjectOptions) SetMatchETag(etag string) error {
if etag == "" {
return ErrInvalidArgument("ETag cannot be empty.")
}
o.Set("If-Match", "\""+etag+"\"")
return nil
} | [
"func",
"(",
"o",
"*",
"GetObjectOptions",
")",
"SetMatchETag",
"(",
"etag",
"string",
")",
"error",
"{",
"if",
"etag",
"==",
"\"",
"\"",
"{",
"return",
"ErrInvalidArgument",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"o",
".",
"Set",
"(",
"\"",
"\"",
... | // SetMatchETag - set match etag. | [
"SetMatchETag",
"-",
"set",
"match",
"etag",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-get-options.go#L64-L70 | train |
minio/minio-go | api-get-options.go | SetUnmodified | func (o *GetObjectOptions) SetUnmodified(modTime time.Time) error {
if modTime.IsZero() {
return ErrInvalidArgument("Modified since cannot be empty.")
}
o.Set("If-Unmodified-Since", modTime.Format(http.TimeFormat))
return nil
} | go | func (o *GetObjectOptions) SetUnmodified(modTime time.Time) error {
if modTime.IsZero() {
return ErrInvalidArgument("Modified since cannot be empty.")
}
o.Set("If-Unmodified-Since", modTime.Format(http.TimeFormat))
return nil
} | [
"func",
"(",
"o",
"*",
"GetObjectOptions",
")",
"SetUnmodified",
"(",
"modTime",
"time",
".",
"Time",
")",
"error",
"{",
"if",
"modTime",
".",
"IsZero",
"(",
")",
"{",
"return",
"ErrInvalidArgument",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"o",
".",
"... | // SetUnmodified - set unmodified time since. | [
"SetUnmodified",
"-",
"set",
"unmodified",
"time",
"since",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-get-options.go#L82-L88 | train |
minio/minio-go | api-put-object-streaming.go | putObjectNoChecksum | func (c Client) putObjectNoChecksum(ctx context.Context, bucketName, objectName string, reader io.Reader, size int64, opts PutObjectOptions) (n int64, err error) {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return 0, err
}
if err := s3utils.CheckValidObjectName(objectName); err != nil {
return 0, err
}
// Size -1 is only supported on Google Cloud Storage, we error
// out in all other situations.
if size < 0 && !s3utils.IsGoogleEndpoint(*c.endpointURL) {
return 0, ErrEntityTooSmall(size, bucketName, objectName)
}
if size > 0 {
if isReadAt(reader) && !isObject(reader) {
seeker, _ := reader.(io.Seeker)
offset, err := seeker.Seek(0, io.SeekCurrent)
if err != nil {
return 0, ErrInvalidArgument(err.Error())
}
reader = io.NewSectionReader(reader.(io.ReaderAt), offset, size)
}
}
// Update progress reader appropriately to the latest offset as we
// read from the source.
readSeeker := newHook(reader, opts.Progress)
// This function does not calculate sha256 and md5sum for payload.
// Execute put object.
st, err := c.putObjectDo(ctx, bucketName, objectName, readSeeker, "", "", size, opts)
if err != nil {
return 0, err
}
if st.Size != size {
return 0, ErrUnexpectedEOF(st.Size, size, bucketName, objectName)
}
return size, nil
} | go | func (c Client) putObjectNoChecksum(ctx context.Context, bucketName, objectName string, reader io.Reader, size int64, opts PutObjectOptions) (n int64, err error) {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return 0, err
}
if err := s3utils.CheckValidObjectName(objectName); err != nil {
return 0, err
}
// Size -1 is only supported on Google Cloud Storage, we error
// out in all other situations.
if size < 0 && !s3utils.IsGoogleEndpoint(*c.endpointURL) {
return 0, ErrEntityTooSmall(size, bucketName, objectName)
}
if size > 0 {
if isReadAt(reader) && !isObject(reader) {
seeker, _ := reader.(io.Seeker)
offset, err := seeker.Seek(0, io.SeekCurrent)
if err != nil {
return 0, ErrInvalidArgument(err.Error())
}
reader = io.NewSectionReader(reader.(io.ReaderAt), offset, size)
}
}
// Update progress reader appropriately to the latest offset as we
// read from the source.
readSeeker := newHook(reader, opts.Progress)
// This function does not calculate sha256 and md5sum for payload.
// Execute put object.
st, err := c.putObjectDo(ctx, bucketName, objectName, readSeeker, "", "", size, opts)
if err != nil {
return 0, err
}
if st.Size != size {
return 0, ErrUnexpectedEOF(st.Size, size, bucketName, objectName)
}
return size, nil
} | [
"func",
"(",
"c",
"Client",
")",
"putObjectNoChecksum",
"(",
"ctx",
"context",
".",
"Context",
",",
"bucketName",
",",
"objectName",
"string",
",",
"reader",
"io",
".",
"Reader",
",",
"size",
"int64",
",",
"opts",
"PutObjectOptions",
")",
"(",
"n",
"int64"... | // putObjectNoChecksum special function used Google Cloud Storage. This special function
// is used for Google Cloud Storage since Google's multipart API is not S3 compatible. | [
"putObjectNoChecksum",
"special",
"function",
"used",
"Google",
"Cloud",
"Storage",
".",
"This",
"special",
"function",
"is",
"used",
"for",
"Google",
"Cloud",
"Storage",
"since",
"Google",
"s",
"multipart",
"API",
"is",
"not",
"S3",
"compatible",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-object-streaming.go#L331-L370 | train |
minio/minio-go | api-put-object-common.go | isReadAt | func isReadAt(reader io.Reader) (ok bool) {
var v *os.File
v, ok = reader.(*os.File)
if ok {
// Stdin, Stdout and Stderr all have *os.File type
// which happen to also be io.ReaderAt compatible
// we need to add special conditions for them to
// be ignored by this function.
for _, f := range []string{
"/dev/stdin",
"/dev/stdout",
"/dev/stderr",
} {
if f == v.Name() {
ok = false
break
}
}
} else {
_, ok = reader.(io.ReaderAt)
}
return
} | go | func isReadAt(reader io.Reader) (ok bool) {
var v *os.File
v, ok = reader.(*os.File)
if ok {
// Stdin, Stdout and Stderr all have *os.File type
// which happen to also be io.ReaderAt compatible
// we need to add special conditions for them to
// be ignored by this function.
for _, f := range []string{
"/dev/stdin",
"/dev/stdout",
"/dev/stderr",
} {
if f == v.Name() {
ok = false
break
}
}
} else {
_, ok = reader.(io.ReaderAt)
}
return
} | [
"func",
"isReadAt",
"(",
"reader",
"io",
".",
"Reader",
")",
"(",
"ok",
"bool",
")",
"{",
"var",
"v",
"*",
"os",
".",
"File",
"\n",
"v",
",",
"ok",
"=",
"reader",
".",
"(",
"*",
"os",
".",
"File",
")",
"\n",
"if",
"ok",
"{",
"// Stdin, Stdout a... | // Verify if reader is a generic ReaderAt | [
"Verify",
"if",
"reader",
"is",
"a",
"generic",
"ReaderAt"
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-object-common.go#L36-L58 | train |
minio/minio-go | api-put-object-common.go | newUploadID | func (c Client) newUploadID(ctx context.Context, bucketName, objectName string, opts PutObjectOptions) (uploadID string, err error) {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return "", err
}
if err := s3utils.CheckValidObjectName(objectName); err != nil {
return "", err
}
// Initiate multipart upload for an object.
initMultipartUploadResult, err := c.initiateMultipartUpload(ctx, bucketName, objectName, opts)
if err != nil {
return "", err
}
return initMultipartUploadResult.UploadID, nil
} | go | func (c Client) newUploadID(ctx context.Context, bucketName, objectName string, opts PutObjectOptions) (uploadID string, err error) {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return "", err
}
if err := s3utils.CheckValidObjectName(objectName); err != nil {
return "", err
}
// Initiate multipart upload for an object.
initMultipartUploadResult, err := c.initiateMultipartUpload(ctx, bucketName, objectName, opts)
if err != nil {
return "", err
}
return initMultipartUploadResult.UploadID, nil
} | [
"func",
"(",
"c",
"Client",
")",
"newUploadID",
"(",
"ctx",
"context",
".",
"Context",
",",
"bucketName",
",",
"objectName",
"string",
",",
"opts",
"PutObjectOptions",
")",
"(",
"uploadID",
"string",
",",
"err",
"error",
")",
"{",
"// Input validation.",
"if... | // getUploadID - fetch upload id if already present for an object name
// or initiate a new request to fetch a new upload id. | [
"getUploadID",
"-",
"fetch",
"upload",
"id",
"if",
"already",
"present",
"for",
"an",
"object",
"name",
"or",
"initiate",
"a",
"new",
"request",
"to",
"fetch",
"a",
"new",
"upload",
"id",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-object-common.go#L123-L138 | train |
minio/minio-go | api-put-object.go | getNumThreads | func (opts PutObjectOptions) getNumThreads() (numThreads int) {
if opts.NumThreads > 0 {
numThreads = int(opts.NumThreads)
} else {
numThreads = totalWorkers
}
return
} | go | func (opts PutObjectOptions) getNumThreads() (numThreads int) {
if opts.NumThreads > 0 {
numThreads = int(opts.NumThreads)
} else {
numThreads = totalWorkers
}
return
} | [
"func",
"(",
"opts",
"PutObjectOptions",
")",
"getNumThreads",
"(",
")",
"(",
"numThreads",
"int",
")",
"{",
"if",
"opts",
".",
"NumThreads",
">",
"0",
"{",
"numThreads",
"=",
"int",
"(",
"opts",
".",
"NumThreads",
")",
"\n",
"}",
"else",
"{",
"numThre... | // getNumThreads - gets the number of threads to be used in the multipart
// put object operation | [
"getNumThreads",
"-",
"gets",
"the",
"number",
"of",
"threads",
"to",
"be",
"used",
"in",
"the",
"multipart",
"put",
"object",
"operation"
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-object.go#L52-L59 | train |
minio/minio-go | api-put-object.go | Header | func (opts PutObjectOptions) Header() (header http.Header) {
header = make(http.Header)
if opts.ContentType != "" {
header["Content-Type"] = []string{opts.ContentType}
} else {
header["Content-Type"] = []string{"application/octet-stream"}
}
if opts.ContentEncoding != "" {
header["Content-Encoding"] = []string{opts.ContentEncoding}
}
if opts.ContentDisposition != "" {
header["Content-Disposition"] = []string{opts.ContentDisposition}
}
if opts.ContentLanguage != "" {
header["Content-Language"] = []string{opts.ContentLanguage}
}
if opts.CacheControl != "" {
header["Cache-Control"] = []string{opts.CacheControl}
}
if opts.ServerSideEncryption != nil {
opts.ServerSideEncryption.Marshal(header)
}
if opts.StorageClass != "" {
header[amzStorageClass] = []string{opts.StorageClass}
}
if opts.WebsiteRedirectLocation != "" {
header[amzWebsiteRedirectLocation] = []string{opts.WebsiteRedirectLocation}
}
for k, v := range opts.UserMetadata {
if !isAmzHeader(k) && !isStandardHeader(k) && !isStorageClassHeader(k) {
header["X-Amz-Meta-"+k] = []string{v}
} else {
header[k] = []string{v}
}
}
return
} | go | func (opts PutObjectOptions) Header() (header http.Header) {
header = make(http.Header)
if opts.ContentType != "" {
header["Content-Type"] = []string{opts.ContentType}
} else {
header["Content-Type"] = []string{"application/octet-stream"}
}
if opts.ContentEncoding != "" {
header["Content-Encoding"] = []string{opts.ContentEncoding}
}
if opts.ContentDisposition != "" {
header["Content-Disposition"] = []string{opts.ContentDisposition}
}
if opts.ContentLanguage != "" {
header["Content-Language"] = []string{opts.ContentLanguage}
}
if opts.CacheControl != "" {
header["Cache-Control"] = []string{opts.CacheControl}
}
if opts.ServerSideEncryption != nil {
opts.ServerSideEncryption.Marshal(header)
}
if opts.StorageClass != "" {
header[amzStorageClass] = []string{opts.StorageClass}
}
if opts.WebsiteRedirectLocation != "" {
header[amzWebsiteRedirectLocation] = []string{opts.WebsiteRedirectLocation}
}
for k, v := range opts.UserMetadata {
if !isAmzHeader(k) && !isStandardHeader(k) && !isStorageClassHeader(k) {
header["X-Amz-Meta-"+k] = []string{v}
} else {
header[k] = []string{v}
}
}
return
} | [
"func",
"(",
"opts",
"PutObjectOptions",
")",
"Header",
"(",
")",
"(",
"header",
"http",
".",
"Header",
")",
"{",
"header",
"=",
"make",
"(",
"http",
".",
"Header",
")",
"\n\n",
"if",
"opts",
".",
"ContentType",
"!=",
"\"",
"\"",
"{",
"header",
"[",
... | // Header - constructs the headers from metadata entered by user in
// PutObjectOptions struct | [
"Header",
"-",
"constructs",
"the",
"headers",
"from",
"metadata",
"entered",
"by",
"user",
"in",
"PutObjectOptions",
"struct"
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-object.go#L63-L100 | train |
minio/minio-go | api-put-object.go | PutObject | func (c Client) PutObject(bucketName, objectName string, reader io.Reader, objectSize int64,
opts PutObjectOptions) (n int64, err error) {
return c.PutObjectWithContext(context.Background(), bucketName, objectName, reader, objectSize, opts)
} | go | func (c Client) PutObject(bucketName, objectName string, reader io.Reader, objectSize int64,
opts PutObjectOptions) (n int64, err error) {
return c.PutObjectWithContext(context.Background(), bucketName, objectName, reader, objectSize, opts)
} | [
"func",
"(",
"c",
"Client",
")",
"PutObject",
"(",
"bucketName",
",",
"objectName",
"string",
",",
"reader",
"io",
".",
"Reader",
",",
"objectSize",
"int64",
",",
"opts",
"PutObjectOptions",
")",
"(",
"n",
"int64",
",",
"err",
"error",
")",
"{",
"return"... | // PutObject creates an object in a bucket.
//
// You must have WRITE permissions on a bucket to create an object.
//
// - For size smaller than 64MiB PutObject automatically does a
// single atomic Put operation.
// - For size larger than 64MiB PutObject automatically does a
// multipart Put operation.
// - For size input as -1 PutObject does a multipart Put operation
// until input stream reaches EOF. Maximum object size that can
// be uploaded through this operation will be 5TiB. | [
"PutObject",
"creates",
"an",
"object",
"in",
"a",
"bucket",
".",
"You",
"must",
"have",
"WRITE",
"permissions",
"on",
"a",
"bucket",
"to",
"create",
"an",
"object",
".",
"-",
"For",
"size",
"smaller",
"than",
"64MiB",
"PutObject",
"automatically",
"does",
... | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-object.go#L134-L137 | train |
minio/minio-go | api-get-object-file.go | FGetObjectWithContext | func (c Client) FGetObjectWithContext(ctx context.Context, bucketName, objectName, filePath string, opts GetObjectOptions) error {
return c.fGetObjectWithContext(ctx, bucketName, objectName, filePath, opts)
} | go | func (c Client) FGetObjectWithContext(ctx context.Context, bucketName, objectName, filePath string, opts GetObjectOptions) error {
return c.fGetObjectWithContext(ctx, bucketName, objectName, filePath, opts)
} | [
"func",
"(",
"c",
"Client",
")",
"FGetObjectWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"bucketName",
",",
"objectName",
",",
"filePath",
"string",
",",
"opts",
"GetObjectOptions",
")",
"error",
"{",
"return",
"c",
".",
"fGetObjectWithContext",
"... | // FGetObjectWithContext - download contents of an object to a local file.
// The options can be used to specify the GET request further. | [
"FGetObjectWithContext",
"-",
"download",
"contents",
"of",
"an",
"object",
"to",
"a",
"local",
"file",
".",
"The",
"options",
"can",
"be",
"used",
"to",
"specify",
"the",
"GET",
"request",
"further",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-get-object-file.go#L31-L33 | train |
minio/minio-go | api-get-object-file.go | FGetObject | func (c Client) FGetObject(bucketName, objectName, filePath string, opts GetObjectOptions) error {
return c.fGetObjectWithContext(context.Background(), bucketName, objectName, filePath, opts)
} | go | func (c Client) FGetObject(bucketName, objectName, filePath string, opts GetObjectOptions) error {
return c.fGetObjectWithContext(context.Background(), bucketName, objectName, filePath, opts)
} | [
"func",
"(",
"c",
"Client",
")",
"FGetObject",
"(",
"bucketName",
",",
"objectName",
",",
"filePath",
"string",
",",
"opts",
"GetObjectOptions",
")",
"error",
"{",
"return",
"c",
".",
"fGetObjectWithContext",
"(",
"context",
".",
"Background",
"(",
")",
",",... | // FGetObject - download contents of an object to a local file. | [
"FGetObject",
"-",
"download",
"contents",
"of",
"an",
"object",
"to",
"a",
"local",
"file",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-get-object-file.go#L36-L38 | train |
minio/minio-go | api-get-object-file.go | fGetObjectWithContext | func (c Client) fGetObjectWithContext(ctx context.Context, bucketName, objectName, filePath string, opts GetObjectOptions) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
}
if err := s3utils.CheckValidObjectName(objectName); err != nil {
return err
}
// Verify if destination already exists.
st, err := os.Stat(filePath)
if err == nil {
// If the destination exists and is a directory.
if st.IsDir() {
return ErrInvalidArgument("fileName is a directory.")
}
}
// Proceed if file does not exist. return for all other errors.
if err != nil {
if !os.IsNotExist(err) {
return err
}
}
// Extract top level directory.
objectDir, _ := filepath.Split(filePath)
if objectDir != "" {
// Create any missing top level directories.
if err := os.MkdirAll(objectDir, 0700); err != nil {
return err
}
}
// Gather md5sum.
objectStat, err := c.StatObject(bucketName, objectName, StatObjectOptions{opts})
if err != nil {
return err
}
// Write to a temporary file "fileName.part.minio" before saving.
filePartPath := filePath + objectStat.ETag + ".part.minio"
// If exists, open in append mode. If not create it as a part file.
filePart, err := os.OpenFile(filePartPath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
if err != nil {
return err
}
// Issue Stat to get the current offset.
st, err = filePart.Stat()
if err != nil {
return err
}
// Initialize get object request headers to set the
// appropriate range offsets to read from.
if st.Size() > 0 {
opts.SetRange(st.Size(), 0)
}
// Seek to current position for incoming reader.
objectReader, objectStat, err := c.getObject(ctx, bucketName, objectName, opts)
if err != nil {
return err
}
// Write to the part file.
if _, err = io.CopyN(filePart, objectReader, objectStat.Size); err != nil {
return err
}
// Close the file before rename, this is specifically needed for Windows users.
if err = filePart.Close(); err != nil {
return err
}
// Safely completed. Now commit by renaming to actual filename.
if err = os.Rename(filePartPath, filePath); err != nil {
return err
}
// Return.
return nil
} | go | func (c Client) fGetObjectWithContext(ctx context.Context, bucketName, objectName, filePath string, opts GetObjectOptions) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
}
if err := s3utils.CheckValidObjectName(objectName); err != nil {
return err
}
// Verify if destination already exists.
st, err := os.Stat(filePath)
if err == nil {
// If the destination exists and is a directory.
if st.IsDir() {
return ErrInvalidArgument("fileName is a directory.")
}
}
// Proceed if file does not exist. return for all other errors.
if err != nil {
if !os.IsNotExist(err) {
return err
}
}
// Extract top level directory.
objectDir, _ := filepath.Split(filePath)
if objectDir != "" {
// Create any missing top level directories.
if err := os.MkdirAll(objectDir, 0700); err != nil {
return err
}
}
// Gather md5sum.
objectStat, err := c.StatObject(bucketName, objectName, StatObjectOptions{opts})
if err != nil {
return err
}
// Write to a temporary file "fileName.part.minio" before saving.
filePartPath := filePath + objectStat.ETag + ".part.minio"
// If exists, open in append mode. If not create it as a part file.
filePart, err := os.OpenFile(filePartPath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
if err != nil {
return err
}
// Issue Stat to get the current offset.
st, err = filePart.Stat()
if err != nil {
return err
}
// Initialize get object request headers to set the
// appropriate range offsets to read from.
if st.Size() > 0 {
opts.SetRange(st.Size(), 0)
}
// Seek to current position for incoming reader.
objectReader, objectStat, err := c.getObject(ctx, bucketName, objectName, opts)
if err != nil {
return err
}
// Write to the part file.
if _, err = io.CopyN(filePart, objectReader, objectStat.Size); err != nil {
return err
}
// Close the file before rename, this is specifically needed for Windows users.
if err = filePart.Close(); err != nil {
return err
}
// Safely completed. Now commit by renaming to actual filename.
if err = os.Rename(filePartPath, filePath); err != nil {
return err
}
// Return.
return nil
} | [
"func",
"(",
"c",
"Client",
")",
"fGetObjectWithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"bucketName",
",",
"objectName",
",",
"filePath",
"string",
",",
"opts",
"GetObjectOptions",
")",
"error",
"{",
"// Input validation.",
"if",
"err",
":=",
"s3... | // fGetObjectWithContext - fgetObject wrapper function with context | [
"fGetObjectWithContext",
"-",
"fgetObject",
"wrapper",
"function",
"with",
"context"
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-get-object-file.go#L41-L125 | train |
minio/minio-go | bucket-cache.go | Get | func (r *bucketLocationCache) Get(bucketName string) (location string, ok bool) {
r.RLock()
defer r.RUnlock()
location, ok = r.items[bucketName]
return
} | go | func (r *bucketLocationCache) Get(bucketName string) (location string, ok bool) {
r.RLock()
defer r.RUnlock()
location, ok = r.items[bucketName]
return
} | [
"func",
"(",
"r",
"*",
"bucketLocationCache",
")",
"Get",
"(",
"bucketName",
"string",
")",
"(",
"location",
"string",
",",
"ok",
"bool",
")",
"{",
"r",
".",
"RLock",
"(",
")",
"\n",
"defer",
"r",
".",
"RUnlock",
"(",
")",
"\n",
"location",
",",
"o... | // Get - Returns a value of a given key if it exists. | [
"Get",
"-",
"Returns",
"a",
"value",
"of",
"a",
"given",
"key",
"if",
"it",
"exists",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/bucket-cache.go#L52-L57 | train |
minio/minio-go | bucket-cache.go | Set | func (r *bucketLocationCache) Set(bucketName string, location string) {
r.Lock()
defer r.Unlock()
r.items[bucketName] = location
} | go | func (r *bucketLocationCache) Set(bucketName string, location string) {
r.Lock()
defer r.Unlock()
r.items[bucketName] = location
} | [
"func",
"(",
"r",
"*",
"bucketLocationCache",
")",
"Set",
"(",
"bucketName",
"string",
",",
"location",
"string",
")",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"Unlock",
"(",
")",
"\n",
"r",
".",
"items",
"[",
"bucketName",
"]",
"=... | // Set - Will persist a value into cache. | [
"Set",
"-",
"Will",
"persist",
"a",
"value",
"into",
"cache",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/bucket-cache.go#L60-L64 | train |
minio/minio-go | bucket-cache.go | Delete | func (r *bucketLocationCache) Delete(bucketName string) {
r.Lock()
defer r.Unlock()
delete(r.items, bucketName)
} | go | func (r *bucketLocationCache) Delete(bucketName string) {
r.Lock()
defer r.Unlock()
delete(r.items, bucketName)
} | [
"func",
"(",
"r",
"*",
"bucketLocationCache",
")",
"Delete",
"(",
"bucketName",
"string",
")",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"r",
".",
"items",
",",
"bucketName",
")",
"\n",
"}"
] | // Delete - Deletes a bucket name from cache. | [
"Delete",
"-",
"Deletes",
"a",
"bucket",
"name",
"from",
"cache",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/bucket-cache.go#L67-L71 | train |
minio/minio-go | bucket-cache.go | GetBucketLocation | func (c Client) GetBucketLocation(bucketName string) (string, error) {
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return "", err
}
return c.getBucketLocation(bucketName)
} | go | func (c Client) GetBucketLocation(bucketName string) (string, error) {
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return "", err
}
return c.getBucketLocation(bucketName)
} | [
"func",
"(",
"c",
"Client",
")",
"GetBucketLocation",
"(",
"bucketName",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"err",
":=",
"s3utils",
".",
"CheckValidBucketName",
"(",
"bucketName",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\""... | // GetBucketLocation - get location for the bucket name from location cache, if not
// fetch freshly by making a new request. | [
"GetBucketLocation",
"-",
"get",
"location",
"for",
"the",
"bucket",
"name",
"from",
"location",
"cache",
"if",
"not",
"fetch",
"freshly",
"by",
"making",
"a",
"new",
"request",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/bucket-cache.go#L75-L80 | train |
minio/minio-go | bucket-cache.go | getBucketLocation | func (c Client) getBucketLocation(bucketName string) (string, error) {
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return "", err
}
// Region set then no need to fetch bucket location.
if c.region != "" {
return c.region, nil
}
if location, ok := c.bucketLocCache.Get(bucketName); ok {
return location, nil
}
// Initialize a new request.
req, err := c.getBucketLocationRequest(bucketName)
if err != nil {
return "", err
}
// Initiate the request.
resp, err := c.do(req)
defer closeResponse(resp)
if err != nil {
return "", err
}
location, err := processBucketLocationResponse(resp, bucketName)
if err != nil {
return "", err
}
c.bucketLocCache.Set(bucketName, location)
return location, nil
} | go | func (c Client) getBucketLocation(bucketName string) (string, error) {
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return "", err
}
// Region set then no need to fetch bucket location.
if c.region != "" {
return c.region, nil
}
if location, ok := c.bucketLocCache.Get(bucketName); ok {
return location, nil
}
// Initialize a new request.
req, err := c.getBucketLocationRequest(bucketName)
if err != nil {
return "", err
}
// Initiate the request.
resp, err := c.do(req)
defer closeResponse(resp)
if err != nil {
return "", err
}
location, err := processBucketLocationResponse(resp, bucketName)
if err != nil {
return "", err
}
c.bucketLocCache.Set(bucketName, location)
return location, nil
} | [
"func",
"(",
"c",
"Client",
")",
"getBucketLocation",
"(",
"bucketName",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"err",
":=",
"s3utils",
".",
"CheckValidBucketName",
"(",
"bucketName",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\""... | // getBucketLocation - Get location for the bucketName from location map cache, if not
// fetch freshly by making a new request. | [
"getBucketLocation",
"-",
"Get",
"location",
"for",
"the",
"bucketName",
"from",
"location",
"map",
"cache",
"if",
"not",
"fetch",
"freshly",
"by",
"making",
"a",
"new",
"request",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/bucket-cache.go#L84-L116 | train |
minio/minio-go | bucket-cache.go | processBucketLocationResponse | func processBucketLocationResponse(resp *http.Response, bucketName string) (bucketLocation string, err error) {
if resp != nil {
if resp.StatusCode != http.StatusOK {
err = httpRespToErrorResponse(resp, bucketName, "")
errResp := ToErrorResponse(err)
// For access denied error, it could be an anonymous
// request. Move forward and let the top level callers
// succeed if possible based on their policy.
if errResp.Code == "AccessDenied" {
return "us-east-1", nil
}
return "", err
}
}
// Extract location.
var locationConstraint string
err = xmlDecoder(resp.Body, &locationConstraint)
if err != nil {
return "", err
}
location := locationConstraint
// Location is empty will be 'us-east-1'.
if location == "" {
location = "us-east-1"
}
// Location can be 'EU' convert it to meaningful 'eu-west-1'.
if location == "EU" {
location = "eu-west-1"
}
// Save the location into cache.
// Return.
return location, nil
} | go | func processBucketLocationResponse(resp *http.Response, bucketName string) (bucketLocation string, err error) {
if resp != nil {
if resp.StatusCode != http.StatusOK {
err = httpRespToErrorResponse(resp, bucketName, "")
errResp := ToErrorResponse(err)
// For access denied error, it could be an anonymous
// request. Move forward and let the top level callers
// succeed if possible based on their policy.
if errResp.Code == "AccessDenied" {
return "us-east-1", nil
}
return "", err
}
}
// Extract location.
var locationConstraint string
err = xmlDecoder(resp.Body, &locationConstraint)
if err != nil {
return "", err
}
location := locationConstraint
// Location is empty will be 'us-east-1'.
if location == "" {
location = "us-east-1"
}
// Location can be 'EU' convert it to meaningful 'eu-west-1'.
if location == "EU" {
location = "eu-west-1"
}
// Save the location into cache.
// Return.
return location, nil
} | [
"func",
"processBucketLocationResponse",
"(",
"resp",
"*",
"http",
".",
"Response",
",",
"bucketName",
"string",
")",
"(",
"bucketLocation",
"string",
",",
"err",
"error",
")",
"{",
"if",
"resp",
"!=",
"nil",
"{",
"if",
"resp",
".",
"StatusCode",
"!=",
"ht... | // processes the getBucketLocation http response from the server. | [
"processes",
"the",
"getBucketLocation",
"http",
"response",
"from",
"the",
"server",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/bucket-cache.go#L119-L156 | train |
minio/minio-go | bucket-cache.go | getBucketLocationRequest | func (c Client) getBucketLocationRequest(bucketName string) (*http.Request, error) {
// Set location query.
urlValues := make(url.Values)
urlValues.Set("location", "")
// Set get bucket location always as path style.
targetURL := c.endpointURL
// as it works in makeTargetURL method from api.go file
if h, p, err := net.SplitHostPort(targetURL.Host); err == nil {
if targetURL.Scheme == "http" && p == "80" || targetURL.Scheme == "https" && p == "443" {
targetURL.Host = h
}
}
targetURL.Path = path.Join(bucketName, "") + "/"
targetURL.RawQuery = urlValues.Encode()
// Get a new HTTP request for the method.
req, err := http.NewRequest("GET", targetURL.String(), nil)
if err != nil {
return nil, err
}
// Set UserAgent for the request.
c.setUserAgent(req)
// Get credentials from the configured credentials provider.
value, err := c.credsProvider.Get()
if err != nil {
return nil, err
}
var (
signerType = value.SignerType
accessKeyID = value.AccessKeyID
secretAccessKey = value.SecretAccessKey
sessionToken = value.SessionToken
)
// Custom signer set then override the behavior.
if c.overrideSignerType != credentials.SignatureDefault {
signerType = c.overrideSignerType
}
// If signerType returned by credentials helper is anonymous,
// then do not sign regardless of signerType override.
if value.SignerType == credentials.SignatureAnonymous {
signerType = credentials.SignatureAnonymous
}
if signerType.IsAnonymous() {
return req, nil
}
if signerType.IsV2() {
// Get Bucket Location calls should be always path style
isVirtualHost := false
req = s3signer.SignV2(*req, accessKeyID, secretAccessKey, isVirtualHost)
return req, nil
}
// Set sha256 sum for signature calculation only with signature version '4'.
contentSha256 := emptySHA256Hex
if c.secure {
contentSha256 = unsignedPayload
}
req.Header.Set("X-Amz-Content-Sha256", contentSha256)
req = s3signer.SignV4(*req, accessKeyID, secretAccessKey, sessionToken, "us-east-1")
return req, nil
} | go | func (c Client) getBucketLocationRequest(bucketName string) (*http.Request, error) {
// Set location query.
urlValues := make(url.Values)
urlValues.Set("location", "")
// Set get bucket location always as path style.
targetURL := c.endpointURL
// as it works in makeTargetURL method from api.go file
if h, p, err := net.SplitHostPort(targetURL.Host); err == nil {
if targetURL.Scheme == "http" && p == "80" || targetURL.Scheme == "https" && p == "443" {
targetURL.Host = h
}
}
targetURL.Path = path.Join(bucketName, "") + "/"
targetURL.RawQuery = urlValues.Encode()
// Get a new HTTP request for the method.
req, err := http.NewRequest("GET", targetURL.String(), nil)
if err != nil {
return nil, err
}
// Set UserAgent for the request.
c.setUserAgent(req)
// Get credentials from the configured credentials provider.
value, err := c.credsProvider.Get()
if err != nil {
return nil, err
}
var (
signerType = value.SignerType
accessKeyID = value.AccessKeyID
secretAccessKey = value.SecretAccessKey
sessionToken = value.SessionToken
)
// Custom signer set then override the behavior.
if c.overrideSignerType != credentials.SignatureDefault {
signerType = c.overrideSignerType
}
// If signerType returned by credentials helper is anonymous,
// then do not sign regardless of signerType override.
if value.SignerType == credentials.SignatureAnonymous {
signerType = credentials.SignatureAnonymous
}
if signerType.IsAnonymous() {
return req, nil
}
if signerType.IsV2() {
// Get Bucket Location calls should be always path style
isVirtualHost := false
req = s3signer.SignV2(*req, accessKeyID, secretAccessKey, isVirtualHost)
return req, nil
}
// Set sha256 sum for signature calculation only with signature version '4'.
contentSha256 := emptySHA256Hex
if c.secure {
contentSha256 = unsignedPayload
}
req.Header.Set("X-Amz-Content-Sha256", contentSha256)
req = s3signer.SignV4(*req, accessKeyID, secretAccessKey, sessionToken, "us-east-1")
return req, nil
} | [
"func",
"(",
"c",
"Client",
")",
"getBucketLocationRequest",
"(",
"bucketName",
"string",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"// Set location query.",
"urlValues",
":=",
"make",
"(",
"url",
".",
"Values",
")",
"\n",
"urlValues",
... | // getBucketLocationRequest - Wrapper creates a new getBucketLocation request. | [
"getBucketLocationRequest",
"-",
"Wrapper",
"creates",
"a",
"new",
"getBucketLocation",
"request",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/bucket-cache.go#L159-L230 | train |
minio/minio-go | pkg/credentials/sts_web_identity.go | NewSTSWebIdentity | func NewSTSWebIdentity(stsEndpoint string, getWebIDTokenExpiry func() (*WebIdentityToken, error)) (*Credentials, error) {
if stsEndpoint == "" {
return nil, errors.New("STS endpoint cannot be empty")
}
if getWebIDTokenExpiry == nil {
return nil, errors.New("Web ID token and expiry retrieval function should be defined")
}
return New(&STSWebIdentity{
Client: &http.Client{
Transport: http.DefaultTransport,
},
stsEndpoint: stsEndpoint,
getWebIDTokenExpiry: getWebIDTokenExpiry,
}), nil
} | go | func NewSTSWebIdentity(stsEndpoint string, getWebIDTokenExpiry func() (*WebIdentityToken, error)) (*Credentials, error) {
if stsEndpoint == "" {
return nil, errors.New("STS endpoint cannot be empty")
}
if getWebIDTokenExpiry == nil {
return nil, errors.New("Web ID token and expiry retrieval function should be defined")
}
return New(&STSWebIdentity{
Client: &http.Client{
Transport: http.DefaultTransport,
},
stsEndpoint: stsEndpoint,
getWebIDTokenExpiry: getWebIDTokenExpiry,
}), nil
} | [
"func",
"NewSTSWebIdentity",
"(",
"stsEndpoint",
"string",
",",
"getWebIDTokenExpiry",
"func",
"(",
")",
"(",
"*",
"WebIdentityToken",
",",
"error",
")",
")",
"(",
"*",
"Credentials",
",",
"error",
")",
"{",
"if",
"stsEndpoint",
"==",
"\"",
"\"",
"{",
"ret... | // NewSTSWebIdentity returns a pointer to a new
// Credentials object wrapping the STSWebIdentity. | [
"NewSTSWebIdentity",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"Credentials",
"object",
"wrapping",
"the",
"STSWebIdentity",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/credentials/sts_web_identity.go#L82-L96 | train |
minio/minio-go | api-get-object.go | GetObject | func (c Client) GetObject(bucketName, objectName string, opts GetObjectOptions) (*Object, error) {
return c.getObjectWithContext(context.Background(), bucketName, objectName, opts)
} | go | func (c Client) GetObject(bucketName, objectName string, opts GetObjectOptions) (*Object, error) {
return c.getObjectWithContext(context.Background(), bucketName, objectName, opts)
} | [
"func",
"(",
"c",
"Client",
")",
"GetObject",
"(",
"bucketName",
",",
"objectName",
"string",
",",
"opts",
"GetObjectOptions",
")",
"(",
"*",
"Object",
",",
"error",
")",
"{",
"return",
"c",
".",
"getObjectWithContext",
"(",
"context",
".",
"Background",
"... | // GetObject - returns an seekable, readable object. | [
"GetObject",
"-",
"returns",
"an",
"seekable",
"readable",
"object",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-get-object.go#L34-L36 | train |
minio/minio-go | api-get-object.go | doGetRequest | func (o *Object) doGetRequest(request getRequest) (getResponse, error) {
o.reqCh <- request
response := <-o.resCh
// Return any error to the top level.
if response.Error != nil {
return response, response.Error
}
// This was the first request.
if !o.isStarted {
// The object has been operated on.
o.isStarted = true
}
// Set the objectInfo if the request was not readAt
// and it hasn't been set before.
if !o.objectInfoSet && !request.isReadAt {
o.objectInfo = response.objectInfo
o.objectInfoSet = true
}
// Set beenRead only if it has not been set before.
if !o.beenRead {
o.beenRead = response.didRead
}
// Data are ready on the wire, no need to reinitiate connection in lower level
o.seekData = false
return response, nil
} | go | func (o *Object) doGetRequest(request getRequest) (getResponse, error) {
o.reqCh <- request
response := <-o.resCh
// Return any error to the top level.
if response.Error != nil {
return response, response.Error
}
// This was the first request.
if !o.isStarted {
// The object has been operated on.
o.isStarted = true
}
// Set the objectInfo if the request was not readAt
// and it hasn't been set before.
if !o.objectInfoSet && !request.isReadAt {
o.objectInfo = response.objectInfo
o.objectInfoSet = true
}
// Set beenRead only if it has not been set before.
if !o.beenRead {
o.beenRead = response.didRead
}
// Data are ready on the wire, no need to reinitiate connection in lower level
o.seekData = false
return response, nil
} | [
"func",
"(",
"o",
"*",
"Object",
")",
"doGetRequest",
"(",
"request",
"getRequest",
")",
"(",
"getResponse",
",",
"error",
")",
"{",
"o",
".",
"reqCh",
"<-",
"request",
"\n",
"response",
":=",
"<-",
"o",
".",
"resCh",
"\n\n",
"// Return any error to the to... | // doGetRequest - sends and blocks on the firstReqCh and reqCh of an object.
// Returns back the size of the buffer read, if anything was read, as well
// as any error encountered. For all first requests sent on the object
// it is also responsible for sending back the objectInfo. | [
"doGetRequest",
"-",
"sends",
"and",
"blocks",
"on",
"the",
"firstReqCh",
"and",
"reqCh",
"of",
"an",
"object",
".",
"Returns",
"back",
"the",
"size",
"of",
"the",
"buffer",
"read",
"if",
"anything",
"was",
"read",
"as",
"well",
"as",
"any",
"error",
"en... | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-get-object.go#L266-L294 | train |
minio/minio-go | api-get-object.go | Stat | func (o *Object) Stat() (ObjectInfo, error) {
if o == nil {
return ObjectInfo{}, ErrInvalidArgument("Object is nil")
}
// Locking.
o.mutex.Lock()
defer o.mutex.Unlock()
if o.prevErr != nil && o.prevErr != io.EOF || o.isClosed {
return ObjectInfo{}, o.prevErr
}
// This is the first request.
if !o.isStarted || !o.objectInfoSet {
// Send the request and get the response.
_, err := o.doGetRequest(getRequest{
isFirstReq: !o.isStarted,
settingObjectInfo: !o.objectInfoSet,
})
if err != nil {
o.prevErr = err
return ObjectInfo{}, err
}
}
return o.objectInfo, nil
} | go | func (o *Object) Stat() (ObjectInfo, error) {
if o == nil {
return ObjectInfo{}, ErrInvalidArgument("Object is nil")
}
// Locking.
o.mutex.Lock()
defer o.mutex.Unlock()
if o.prevErr != nil && o.prevErr != io.EOF || o.isClosed {
return ObjectInfo{}, o.prevErr
}
// This is the first request.
if !o.isStarted || !o.objectInfoSet {
// Send the request and get the response.
_, err := o.doGetRequest(getRequest{
isFirstReq: !o.isStarted,
settingObjectInfo: !o.objectInfoSet,
})
if err != nil {
o.prevErr = err
return ObjectInfo{}, err
}
}
return o.objectInfo, nil
} | [
"func",
"(",
"o",
"*",
"Object",
")",
"Stat",
"(",
")",
"(",
"ObjectInfo",
",",
"error",
")",
"{",
"if",
"o",
"==",
"nil",
"{",
"return",
"ObjectInfo",
"{",
"}",
",",
"ErrInvalidArgument",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"// Locking.",
"o",
... | // Stat returns the ObjectInfo structure describing Object. | [
"Stat",
"returns",
"the",
"ObjectInfo",
"structure",
"describing",
"Object",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-get-object.go#L364-L390 | train |
minio/minio-go | api-presigned.go | presignURL | func (c Client) presignURL(method string, bucketName string, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) {
// Input validation.
if method == "" {
return nil, ErrInvalidArgument("method cannot be empty.")
}
if err = s3utils.CheckValidBucketName(bucketName); err != nil {
return nil, err
}
if err = isValidExpiry(expires); err != nil {
return nil, err
}
// Convert expires into seconds.
expireSeconds := int64(expires / time.Second)
reqMetadata := requestMetadata{
presignURL: true,
bucketName: bucketName,
objectName: objectName,
expires: expireSeconds,
queryValues: reqParams,
}
// Instantiate a new request.
// Since expires is set newRequest will presign the request.
var req *http.Request
if req, err = c.newRequest(method, reqMetadata); err != nil {
return nil, err
}
return req.URL, nil
} | go | func (c Client) presignURL(method string, bucketName string, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) {
// Input validation.
if method == "" {
return nil, ErrInvalidArgument("method cannot be empty.")
}
if err = s3utils.CheckValidBucketName(bucketName); err != nil {
return nil, err
}
if err = isValidExpiry(expires); err != nil {
return nil, err
}
// Convert expires into seconds.
expireSeconds := int64(expires / time.Second)
reqMetadata := requestMetadata{
presignURL: true,
bucketName: bucketName,
objectName: objectName,
expires: expireSeconds,
queryValues: reqParams,
}
// Instantiate a new request.
// Since expires is set newRequest will presign the request.
var req *http.Request
if req, err = c.newRequest(method, reqMetadata); err != nil {
return nil, err
}
return req.URL, nil
} | [
"func",
"(",
"c",
"Client",
")",
"presignURL",
"(",
"method",
"string",
",",
"bucketName",
"string",
",",
"objectName",
"string",
",",
"expires",
"time",
".",
"Duration",
",",
"reqParams",
"url",
".",
"Values",
")",
"(",
"u",
"*",
"url",
".",
"URL",
",... | // presignURL - Returns a presigned URL for an input 'method'.
// Expires maximum is 7days - ie. 604800 and minimum is 1. | [
"presignURL",
"-",
"Returns",
"a",
"presigned",
"URL",
"for",
"an",
"input",
"method",
".",
"Expires",
"maximum",
"is",
"7days",
"-",
"ie",
".",
"604800",
"and",
"minimum",
"is",
"1",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-presigned.go#L32-L61 | train |
minio/minio-go | api-presigned.go | PresignedGetObject | func (c Client) PresignedGetObject(bucketName string, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) {
if err = s3utils.CheckValidObjectName(objectName); err != nil {
return nil, err
}
return c.presignURL("GET", bucketName, objectName, expires, reqParams)
} | go | func (c Client) PresignedGetObject(bucketName string, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) {
if err = s3utils.CheckValidObjectName(objectName); err != nil {
return nil, err
}
return c.presignURL("GET", bucketName, objectName, expires, reqParams)
} | [
"func",
"(",
"c",
"Client",
")",
"PresignedGetObject",
"(",
"bucketName",
"string",
",",
"objectName",
"string",
",",
"expires",
"time",
".",
"Duration",
",",
"reqParams",
"url",
".",
"Values",
")",
"(",
"u",
"*",
"url",
".",
"URL",
",",
"err",
"error",
... | // PresignedGetObject - Returns a presigned URL to access an object
// data without credentials. URL can have a maximum expiry of
// upto 7days or a minimum of 1sec. Additionally you can override
// a set of response headers using the query parameters. | [
"PresignedGetObject",
"-",
"Returns",
"a",
"presigned",
"URL",
"to",
"access",
"an",
"object",
"data",
"without",
"credentials",
".",
"URL",
"can",
"have",
"a",
"maximum",
"expiry",
"of",
"upto",
"7days",
"or",
"a",
"minimum",
"of",
"1sec",
".",
"Additionall... | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-presigned.go#L67-L72 | train |
minio/minio-go | api-presigned.go | Presign | func (c Client) Presign(method string, bucketName string, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) {
return c.presignURL(method, bucketName, objectName, expires, reqParams)
} | go | func (c Client) Presign(method string, bucketName string, objectName string, expires time.Duration, reqParams url.Values) (u *url.URL, err error) {
return c.presignURL(method, bucketName, objectName, expires, reqParams)
} | [
"func",
"(",
"c",
"Client",
")",
"Presign",
"(",
"method",
"string",
",",
"bucketName",
"string",
",",
"objectName",
"string",
",",
"expires",
"time",
".",
"Duration",
",",
"reqParams",
"url",
".",
"Values",
")",
"(",
"u",
"*",
"url",
".",
"URL",
",",
... | // Presign - returns a presigned URL for any http method of your choice
// along with custom request params. URL can have a maximum expiry of
// upto 7days or a minimum of 1sec. | [
"Presign",
"-",
"returns",
"a",
"presigned",
"URL",
"for",
"any",
"http",
"method",
"of",
"your",
"choice",
"along",
"with",
"custom",
"request",
"params",
".",
"URL",
"can",
"have",
"a",
"maximum",
"expiry",
"of",
"upto",
"7days",
"or",
"a",
"minimum",
... | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-presigned.go#L98-L100 | train |
minio/minio-go | pkg/encrypt/server-side.go | NewSSEKMS | func NewSSEKMS(keyID string, context interface{}) (ServerSide, error) {
if context == nil {
return kms{key: keyID, hasContext: false}, nil
}
serializedContext, err := json.Marshal(context)
if err != nil {
return nil, err
}
return kms{key: keyID, context: serializedContext, hasContext: true}, nil
} | go | func NewSSEKMS(keyID string, context interface{}) (ServerSide, error) {
if context == nil {
return kms{key: keyID, hasContext: false}, nil
}
serializedContext, err := json.Marshal(context)
if err != nil {
return nil, err
}
return kms{key: keyID, context: serializedContext, hasContext: true}, nil
} | [
"func",
"NewSSEKMS",
"(",
"keyID",
"string",
",",
"context",
"interface",
"{",
"}",
")",
"(",
"ServerSide",
",",
"error",
")",
"{",
"if",
"context",
"==",
"nil",
"{",
"return",
"kms",
"{",
"key",
":",
"keyID",
",",
"hasContext",
":",
"false",
"}",
",... | // NewSSEKMS returns a new server-side-encryption using SSE-KMS and the provided Key Id and context. | [
"NewSSEKMS",
"returns",
"a",
"new",
"server",
"-",
"side",
"-",
"encryption",
"using",
"SSE",
"-",
"KMS",
"and",
"the",
"provided",
"Key",
"Id",
"and",
"context",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/encrypt/server-side.go#L100-L109 | train |
minio/minio-go | pkg/encrypt/server-side.go | NewSSEC | func NewSSEC(key []byte) (ServerSide, error) {
if len(key) != 32 {
return nil, errors.New("encrypt: SSE-C key must be 256 bit long")
}
sse := ssec{}
copy(sse[:], key)
return sse, nil
} | go | func NewSSEC(key []byte) (ServerSide, error) {
if len(key) != 32 {
return nil, errors.New("encrypt: SSE-C key must be 256 bit long")
}
sse := ssec{}
copy(sse[:], key)
return sse, nil
} | [
"func",
"NewSSEC",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"ServerSide",
",",
"error",
")",
"{",
"if",
"len",
"(",
"key",
")",
"!=",
"32",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"sse",
":=",
"s... | // NewSSEC returns a new server-side-encryption using SSE-C and the provided key.
// The key must be 32 bytes long. | [
"NewSSEC",
"returns",
"a",
"new",
"server",
"-",
"side",
"-",
"encryption",
"using",
"SSE",
"-",
"C",
"and",
"the",
"provided",
"key",
".",
"The",
"key",
"must",
"be",
"32",
"bytes",
"long",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/encrypt/server-side.go#L113-L120 | train |
minio/minio-go | pkg/policy/bucket-policy-condition.go | Add | func (ckm ConditionKeyMap) Add(key string, value set.StringSet) {
if v, ok := ckm[key]; ok {
ckm[key] = v.Union(value)
} else {
ckm[key] = set.CopyStringSet(value)
}
} | go | func (ckm ConditionKeyMap) Add(key string, value set.StringSet) {
if v, ok := ckm[key]; ok {
ckm[key] = v.Union(value)
} else {
ckm[key] = set.CopyStringSet(value)
}
} | [
"func",
"(",
"ckm",
"ConditionKeyMap",
")",
"Add",
"(",
"key",
"string",
",",
"value",
"set",
".",
"StringSet",
")",
"{",
"if",
"v",
",",
"ok",
":=",
"ckm",
"[",
"key",
"]",
";",
"ok",
"{",
"ckm",
"[",
"key",
"]",
"=",
"v",
".",
"Union",
"(",
... | // Add - adds key and value. The value is appended If key already exists. | [
"Add",
"-",
"adds",
"key",
"and",
"value",
".",
"The",
"value",
"is",
"appended",
"If",
"key",
"already",
"exists",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/policy/bucket-policy-condition.go#L26-L32 | train |
minio/minio-go | pkg/policy/bucket-policy-condition.go | Remove | func (ckm ConditionKeyMap) Remove(key string, value set.StringSet) {
if v, ok := ckm[key]; ok {
if value != nil {
ckm[key] = v.Difference(value)
}
if ckm[key].IsEmpty() {
delete(ckm, key)
}
}
} | go | func (ckm ConditionKeyMap) Remove(key string, value set.StringSet) {
if v, ok := ckm[key]; ok {
if value != nil {
ckm[key] = v.Difference(value)
}
if ckm[key].IsEmpty() {
delete(ckm, key)
}
}
} | [
"func",
"(",
"ckm",
"ConditionKeyMap",
")",
"Remove",
"(",
"key",
"string",
",",
"value",
"set",
".",
"StringSet",
")",
"{",
"if",
"v",
",",
"ok",
":=",
"ckm",
"[",
"key",
"]",
";",
"ok",
"{",
"if",
"value",
"!=",
"nil",
"{",
"ckm",
"[",
"key",
... | // Remove - removes value of given key. If key has empty after removal, the key is also removed. | [
"Remove",
"-",
"removes",
"value",
"of",
"given",
"key",
".",
"If",
"key",
"has",
"empty",
"after",
"removal",
"the",
"key",
"is",
"also",
"removed",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/policy/bucket-policy-condition.go#L35-L45 | train |
minio/minio-go | pkg/policy/bucket-policy-condition.go | RemoveKey | func (ckm ConditionKeyMap) RemoveKey(key string) {
if _, ok := ckm[key]; ok {
delete(ckm, key)
}
} | go | func (ckm ConditionKeyMap) RemoveKey(key string) {
if _, ok := ckm[key]; ok {
delete(ckm, key)
}
} | [
"func",
"(",
"ckm",
"ConditionKeyMap",
")",
"RemoveKey",
"(",
"key",
"string",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"ckm",
"[",
"key",
"]",
";",
"ok",
"{",
"delete",
"(",
"ckm",
",",
"key",
")",
"\n",
"}",
"\n",
"}"
] | // RemoveKey - removes key and its value. | [
"RemoveKey",
"-",
"removes",
"key",
"and",
"its",
"value",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/policy/bucket-policy-condition.go#L48-L52 | train |
minio/minio-go | pkg/policy/bucket-policy-condition.go | CopyConditionKeyMap | func CopyConditionKeyMap(condKeyMap ConditionKeyMap) ConditionKeyMap {
out := make(ConditionKeyMap)
for k, v := range condKeyMap {
out[k] = set.CopyStringSet(v)
}
return out
} | go | func CopyConditionKeyMap(condKeyMap ConditionKeyMap) ConditionKeyMap {
out := make(ConditionKeyMap)
for k, v := range condKeyMap {
out[k] = set.CopyStringSet(v)
}
return out
} | [
"func",
"CopyConditionKeyMap",
"(",
"condKeyMap",
"ConditionKeyMap",
")",
"ConditionKeyMap",
"{",
"out",
":=",
"make",
"(",
"ConditionKeyMap",
")",
"\n\n",
"for",
"k",
",",
"v",
":=",
"range",
"condKeyMap",
"{",
"out",
"[",
"k",
"]",
"=",
"set",
".",
"Copy... | // CopyConditionKeyMap - returns new copy of given ConditionKeyMap. | [
"CopyConditionKeyMap",
"-",
"returns",
"new",
"copy",
"of",
"given",
"ConditionKeyMap",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/policy/bucket-policy-condition.go#L55-L63 | train |
minio/minio-go | pkg/policy/bucket-policy-condition.go | Add | func (cond ConditionMap) Add(condKey string, condKeyMap ConditionKeyMap) {
if v, ok := cond[condKey]; ok {
cond[condKey] = mergeConditionKeyMap(v, condKeyMap)
} else {
cond[condKey] = CopyConditionKeyMap(condKeyMap)
}
} | go | func (cond ConditionMap) Add(condKey string, condKeyMap ConditionKeyMap) {
if v, ok := cond[condKey]; ok {
cond[condKey] = mergeConditionKeyMap(v, condKeyMap)
} else {
cond[condKey] = CopyConditionKeyMap(condKeyMap)
}
} | [
"func",
"(",
"cond",
"ConditionMap",
")",
"Add",
"(",
"condKey",
"string",
",",
"condKeyMap",
"ConditionKeyMap",
")",
"{",
"if",
"v",
",",
"ok",
":=",
"cond",
"[",
"condKey",
"]",
";",
"ok",
"{",
"cond",
"[",
"condKey",
"]",
"=",
"mergeConditionKeyMap",
... | // Add - adds condition key and condition value. The value is appended if key already exists. | [
"Add",
"-",
"adds",
"condition",
"key",
"and",
"condition",
"value",
".",
"The",
"value",
"is",
"appended",
"if",
"key",
"already",
"exists",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/policy/bucket-policy-condition.go#L84-L90 | train |
minio/minio-go | pkg/policy/bucket-policy-condition.go | Remove | func (cond ConditionMap) Remove(condKey string) {
if _, ok := cond[condKey]; ok {
delete(cond, condKey)
}
} | go | func (cond ConditionMap) Remove(condKey string) {
if _, ok := cond[condKey]; ok {
delete(cond, condKey)
}
} | [
"func",
"(",
"cond",
"ConditionMap",
")",
"Remove",
"(",
"condKey",
"string",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"cond",
"[",
"condKey",
"]",
";",
"ok",
"{",
"delete",
"(",
"cond",
",",
"condKey",
")",
"\n",
"}",
"\n",
"}"
] | // Remove - removes condition key and its value. | [
"Remove",
"-",
"removes",
"condition",
"key",
"and",
"its",
"value",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/policy/bucket-policy-condition.go#L93-L97 | train |
minio/minio-go | pkg/s3utils/utils.go | IsValidDomain | func IsValidDomain(host string) bool {
// See RFC 1035, RFC 3696.
host = strings.TrimSpace(host)
if len(host) == 0 || len(host) > 255 {
return false
}
// host cannot start or end with "-"
if host[len(host)-1:] == "-" || host[:1] == "-" {
return false
}
// host cannot start or end with "_"
if host[len(host)-1:] == "_" || host[:1] == "_" {
return false
}
// host cannot start or end with a "."
if host[len(host)-1:] == "." || host[:1] == "." {
return false
}
// All non alphanumeric characters are invalid.
if strings.ContainsAny(host, "`~!@#$%^&*()+={}[]|\\\"';:><?/") {
return false
}
// No need to regexp match, since the list is non-exhaustive.
// We let it valid and fail later.
return true
} | go | func IsValidDomain(host string) bool {
// See RFC 1035, RFC 3696.
host = strings.TrimSpace(host)
if len(host) == 0 || len(host) > 255 {
return false
}
// host cannot start or end with "-"
if host[len(host)-1:] == "-" || host[:1] == "-" {
return false
}
// host cannot start or end with "_"
if host[len(host)-1:] == "_" || host[:1] == "_" {
return false
}
// host cannot start or end with a "."
if host[len(host)-1:] == "." || host[:1] == "." {
return false
}
// All non alphanumeric characters are invalid.
if strings.ContainsAny(host, "`~!@#$%^&*()+={}[]|\\\"';:><?/") {
return false
}
// No need to regexp match, since the list is non-exhaustive.
// We let it valid and fail later.
return true
} | [
"func",
"IsValidDomain",
"(",
"host",
"string",
")",
"bool",
"{",
"// See RFC 1035, RFC 3696.",
"host",
"=",
"strings",
".",
"TrimSpace",
"(",
"host",
")",
"\n",
"if",
"len",
"(",
"host",
")",
"==",
"0",
"||",
"len",
"(",
"host",
")",
">",
"255",
"{",
... | // IsValidDomain validates if input string is a valid domain name. | [
"IsValidDomain",
"validates",
"if",
"input",
"string",
"is",
"a",
"valid",
"domain",
"name",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3utils/utils.go#L36-L61 | train |
minio/minio-go | pkg/s3utils/utils.go | IsVirtualHostSupported | func IsVirtualHostSupported(endpointURL url.URL, bucketName string) bool {
if endpointURL == sentinelURL {
return false
}
// bucketName can be valid but '.' in the hostname will fail SSL
// certificate validation. So do not use host-style for such buckets.
if endpointURL.Scheme == "https" && strings.Contains(bucketName, ".") {
return false
}
// Return true for all other cases
return IsAmazonEndpoint(endpointURL) || IsGoogleEndpoint(endpointURL)
} | go | func IsVirtualHostSupported(endpointURL url.URL, bucketName string) bool {
if endpointURL == sentinelURL {
return false
}
// bucketName can be valid but '.' in the hostname will fail SSL
// certificate validation. So do not use host-style for such buckets.
if endpointURL.Scheme == "https" && strings.Contains(bucketName, ".") {
return false
}
// Return true for all other cases
return IsAmazonEndpoint(endpointURL) || IsGoogleEndpoint(endpointURL)
} | [
"func",
"IsVirtualHostSupported",
"(",
"endpointURL",
"url",
".",
"URL",
",",
"bucketName",
"string",
")",
"bool",
"{",
"if",
"endpointURL",
"==",
"sentinelURL",
"{",
"return",
"false",
"\n",
"}",
"\n",
"// bucketName can be valid but '.' in the hostname will fail SSL",... | // IsVirtualHostSupported - verifies if bucketName can be part of
// virtual host. Currently only Amazon S3 and Google Cloud Storage
// would support this. | [
"IsVirtualHostSupported",
"-",
"verifies",
"if",
"bucketName",
"can",
"be",
"part",
"of",
"virtual",
"host",
".",
"Currently",
"only",
"Amazon",
"S3",
"and",
"Google",
"Cloud",
"Storage",
"would",
"support",
"this",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3utils/utils.go#L71-L82 | train |
minio/minio-go | pkg/s3utils/utils.go | GetRegionFromURL | func GetRegionFromURL(endpointURL url.URL) string {
if endpointURL == sentinelURL {
return ""
}
if endpointURL.Host == "s3-external-1.amazonaws.com" {
return ""
}
if IsAmazonGovCloudEndpoint(endpointURL) {
return "us-gov-west-1"
}
parts := amazonS3HostDualStack.FindStringSubmatch(endpointURL.Host)
if len(parts) > 1 {
return parts[1]
}
parts = amazonS3HostHyphen.FindStringSubmatch(endpointURL.Host)
if len(parts) > 1 {
return parts[1]
}
parts = amazonS3ChinaHost.FindStringSubmatch(endpointURL.Host)
if len(parts) > 1 {
return parts[1]
}
parts = amazonS3HostDot.FindStringSubmatch(endpointURL.Host)
if len(parts) > 1 {
return parts[1]
}
return ""
} | go | func GetRegionFromURL(endpointURL url.URL) string {
if endpointURL == sentinelURL {
return ""
}
if endpointURL.Host == "s3-external-1.amazonaws.com" {
return ""
}
if IsAmazonGovCloudEndpoint(endpointURL) {
return "us-gov-west-1"
}
parts := amazonS3HostDualStack.FindStringSubmatch(endpointURL.Host)
if len(parts) > 1 {
return parts[1]
}
parts = amazonS3HostHyphen.FindStringSubmatch(endpointURL.Host)
if len(parts) > 1 {
return parts[1]
}
parts = amazonS3ChinaHost.FindStringSubmatch(endpointURL.Host)
if len(parts) > 1 {
return parts[1]
}
parts = amazonS3HostDot.FindStringSubmatch(endpointURL.Host)
if len(parts) > 1 {
return parts[1]
}
return ""
} | [
"func",
"GetRegionFromURL",
"(",
"endpointURL",
"url",
".",
"URL",
")",
"string",
"{",
"if",
"endpointURL",
"==",
"sentinelURL",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"endpointURL",
".",
"Host",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
... | // GetRegionFromURL - returns a region from url host. | [
"GetRegionFromURL",
"-",
"returns",
"a",
"region",
"from",
"url",
"host",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3utils/utils.go#L99-L126 | train |
minio/minio-go | pkg/s3utils/utils.go | IsAmazonEndpoint | func IsAmazonEndpoint(endpointURL url.URL) bool {
if endpointURL.Host == "s3-external-1.amazonaws.com" || endpointURL.Host == "s3.amazonaws.com" {
return true
}
return GetRegionFromURL(endpointURL) != ""
} | go | func IsAmazonEndpoint(endpointURL url.URL) bool {
if endpointURL.Host == "s3-external-1.amazonaws.com" || endpointURL.Host == "s3.amazonaws.com" {
return true
}
return GetRegionFromURL(endpointURL) != ""
} | [
"func",
"IsAmazonEndpoint",
"(",
"endpointURL",
"url",
".",
"URL",
")",
"bool",
"{",
"if",
"endpointURL",
".",
"Host",
"==",
"\"",
"\"",
"||",
"endpointURL",
".",
"Host",
"==",
"\"",
"\"",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"GetRegionFromU... | // IsAmazonEndpoint - Match if it is exactly Amazon S3 endpoint. | [
"IsAmazonEndpoint",
"-",
"Match",
"if",
"it",
"is",
"exactly",
"Amazon",
"S3",
"endpoint",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3utils/utils.go#L129-L134 | train |
minio/minio-go | pkg/s3utils/utils.go | IsAmazonGovCloudEndpoint | func IsAmazonGovCloudEndpoint(endpointURL url.URL) bool {
if endpointURL == sentinelURL {
return false
}
return (endpointURL.Host == "s3-us-gov-west-1.amazonaws.com" ||
IsAmazonFIPSGovCloudEndpoint(endpointURL))
} | go | func IsAmazonGovCloudEndpoint(endpointURL url.URL) bool {
if endpointURL == sentinelURL {
return false
}
return (endpointURL.Host == "s3-us-gov-west-1.amazonaws.com" ||
IsAmazonFIPSGovCloudEndpoint(endpointURL))
} | [
"func",
"IsAmazonGovCloudEndpoint",
"(",
"endpointURL",
"url",
".",
"URL",
")",
"bool",
"{",
"if",
"endpointURL",
"==",
"sentinelURL",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"(",
"endpointURL",
".",
"Host",
"==",
"\"",
"\"",
"||",
"IsAmazonFIPSGo... | // IsAmazonGovCloudEndpoint - Match if it is exactly Amazon S3 GovCloud endpoint. | [
"IsAmazonGovCloudEndpoint",
"-",
"Match",
"if",
"it",
"is",
"exactly",
"Amazon",
"S3",
"GovCloud",
"endpoint",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3utils/utils.go#L137-L143 | train |
minio/minio-go | pkg/s3utils/utils.go | IsGoogleEndpoint | func IsGoogleEndpoint(endpointURL url.URL) bool {
if endpointURL == sentinelURL {
return false
}
return endpointURL.Host == "storage.googleapis.com"
} | go | func IsGoogleEndpoint(endpointURL url.URL) bool {
if endpointURL == sentinelURL {
return false
}
return endpointURL.Host == "storage.googleapis.com"
} | [
"func",
"IsGoogleEndpoint",
"(",
"endpointURL",
"url",
".",
"URL",
")",
"bool",
"{",
"if",
"endpointURL",
"==",
"sentinelURL",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"endpointURL",
".",
"Host",
"==",
"\"",
"\"",
"\n",
"}"
] | // IsGoogleEndpoint - Match if it is exactly Google cloud storage endpoint. | [
"IsGoogleEndpoint",
"-",
"Match",
"if",
"it",
"is",
"exactly",
"Google",
"cloud",
"storage",
"endpoint",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3utils/utils.go#L183-L188 | train |
minio/minio-go | pkg/s3utils/utils.go | checkBucketNameCommon | func checkBucketNameCommon(bucketName string, strict bool) (err error) {
if strings.TrimSpace(bucketName) == "" {
return errors.New("Bucket name cannot be empty")
}
if len(bucketName) < 3 {
return errors.New("Bucket name cannot be smaller than 3 characters")
}
if len(bucketName) > 63 {
return errors.New("Bucket name cannot be greater than 63 characters")
}
if ipAddress.MatchString(bucketName) {
return errors.New("Bucket name cannot be an ip address")
}
if strings.Contains(bucketName, "..") || strings.Contains(bucketName, ".-") || strings.Contains(bucketName, "-.") {
return errors.New("Bucket name contains invalid characters")
}
if strict {
if !validBucketNameStrict.MatchString(bucketName) {
err = errors.New("Bucket name contains invalid characters")
}
return err
}
if !validBucketName.MatchString(bucketName) {
err = errors.New("Bucket name contains invalid characters")
}
return err
} | go | func checkBucketNameCommon(bucketName string, strict bool) (err error) {
if strings.TrimSpace(bucketName) == "" {
return errors.New("Bucket name cannot be empty")
}
if len(bucketName) < 3 {
return errors.New("Bucket name cannot be smaller than 3 characters")
}
if len(bucketName) > 63 {
return errors.New("Bucket name cannot be greater than 63 characters")
}
if ipAddress.MatchString(bucketName) {
return errors.New("Bucket name cannot be an ip address")
}
if strings.Contains(bucketName, "..") || strings.Contains(bucketName, ".-") || strings.Contains(bucketName, "-.") {
return errors.New("Bucket name contains invalid characters")
}
if strict {
if !validBucketNameStrict.MatchString(bucketName) {
err = errors.New("Bucket name contains invalid characters")
}
return err
}
if !validBucketName.MatchString(bucketName) {
err = errors.New("Bucket name contains invalid characters")
}
return err
} | [
"func",
"checkBucketNameCommon",
"(",
"bucketName",
"string",
",",
"strict",
"bool",
")",
"(",
"err",
"error",
")",
"{",
"if",
"strings",
".",
"TrimSpace",
"(",
"bucketName",
")",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
... | // Common checker for both stricter and basic validation. | [
"Common",
"checker",
"for",
"both",
"stricter",
"and",
"basic",
"validation",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3utils/utils.go#L272-L298 | train |
minio/minio-go | core.go | NewCore | func NewCore(endpoint string, accessKeyID, secretAccessKey string, secure bool) (*Core, error) {
var s3Client Core
client, err := NewV4(endpoint, accessKeyID, secretAccessKey, secure)
if err != nil {
return nil, err
}
s3Client.Client = client
return &s3Client, nil
} | go | func NewCore(endpoint string, accessKeyID, secretAccessKey string, secure bool) (*Core, error) {
var s3Client Core
client, err := NewV4(endpoint, accessKeyID, secretAccessKey, secure)
if err != nil {
return nil, err
}
s3Client.Client = client
return &s3Client, nil
} | [
"func",
"NewCore",
"(",
"endpoint",
"string",
",",
"accessKeyID",
",",
"secretAccessKey",
"string",
",",
"secure",
"bool",
")",
"(",
"*",
"Core",
",",
"error",
")",
"{",
"var",
"s3Client",
"Core",
"\n",
"client",
",",
"err",
":=",
"NewV4",
"(",
"endpoint... | // NewCore - Returns new initialized a Core client, this CoreClient should be
// only used under special conditions such as need to access lower primitives
// and being able to use them to write your own wrappers. | [
"NewCore",
"-",
"Returns",
"new",
"initialized",
"a",
"Core",
"client",
"this",
"CoreClient",
"should",
"be",
"only",
"used",
"under",
"special",
"conditions",
"such",
"as",
"need",
"to",
"access",
"lower",
"primitives",
"and",
"being",
"able",
"to",
"use",
... | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L36-L44 | train |
minio/minio-go | core.go | ListObjects | func (c Core) ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (result ListBucketResult, err error) {
return c.listObjectsQuery(bucket, prefix, marker, delimiter, maxKeys)
} | go | func (c Core) ListObjects(bucket, prefix, marker, delimiter string, maxKeys int) (result ListBucketResult, err error) {
return c.listObjectsQuery(bucket, prefix, marker, delimiter, maxKeys)
} | [
"func",
"(",
"c",
"Core",
")",
"ListObjects",
"(",
"bucket",
",",
"prefix",
",",
"marker",
",",
"delimiter",
"string",
",",
"maxKeys",
"int",
")",
"(",
"result",
"ListBucketResult",
",",
"err",
"error",
")",
"{",
"return",
"c",
".",
"listObjectsQuery",
"... | // ListObjects - List all the objects at a prefix, optionally with marker and delimiter
// you can further filter the results. | [
"ListObjects",
"-",
"List",
"all",
"the",
"objects",
"at",
"a",
"prefix",
"optionally",
"with",
"marker",
"and",
"delimiter",
"you",
"can",
"further",
"filter",
"the",
"results",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L48-L50 | train |
minio/minio-go | core.go | CopyObject | func (c Core) CopyObject(sourceBucket, sourceObject, destBucket, destObject string, metadata map[string]string) (ObjectInfo, error) {
return c.copyObjectDo(context.Background(), sourceBucket, sourceObject, destBucket, destObject, metadata)
} | go | func (c Core) CopyObject(sourceBucket, sourceObject, destBucket, destObject string, metadata map[string]string) (ObjectInfo, error) {
return c.copyObjectDo(context.Background(), sourceBucket, sourceObject, destBucket, destObject, metadata)
} | [
"func",
"(",
"c",
"Core",
")",
"CopyObject",
"(",
"sourceBucket",
",",
"sourceObject",
",",
"destBucket",
",",
"destObject",
"string",
",",
"metadata",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"ObjectInfo",
",",
"error",
")",
"{",
"return",
"c",
".... | // CopyObject - copies an object from source object to destination object on server side. | [
"CopyObject",
"-",
"copies",
"an",
"object",
"from",
"source",
"object",
"to",
"destination",
"object",
"on",
"server",
"side",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L59-L61 | train |
minio/minio-go | core.go | PutObject | func (c Core) PutObject(bucket, object string, data io.Reader, size int64, md5Base64, sha256Hex string, metadata map[string]string, sse encrypt.ServerSide) (ObjectInfo, error) {
opts := PutObjectOptions{}
m := make(map[string]string)
for k, v := range metadata {
if strings.ToLower(k) == "content-encoding" {
opts.ContentEncoding = v
} else if strings.ToLower(k) == "content-disposition" {
opts.ContentDisposition = v
} else if strings.ToLower(k) == "content-language" {
opts.ContentLanguage = v
} else if strings.ToLower(k) == "content-type" {
opts.ContentType = v
} else if strings.ToLower(k) == "cache-control" {
opts.CacheControl = v
} else if strings.ToLower(k) == strings.ToLower(amzWebsiteRedirectLocation) {
opts.WebsiteRedirectLocation = v
} else {
m[k] = metadata[k]
}
}
opts.UserMetadata = m
opts.ServerSideEncryption = sse
return c.putObjectDo(context.Background(), bucket, object, data, md5Base64, sha256Hex, size, opts)
} | go | func (c Core) PutObject(bucket, object string, data io.Reader, size int64, md5Base64, sha256Hex string, metadata map[string]string, sse encrypt.ServerSide) (ObjectInfo, error) {
opts := PutObjectOptions{}
m := make(map[string]string)
for k, v := range metadata {
if strings.ToLower(k) == "content-encoding" {
opts.ContentEncoding = v
} else if strings.ToLower(k) == "content-disposition" {
opts.ContentDisposition = v
} else if strings.ToLower(k) == "content-language" {
opts.ContentLanguage = v
} else if strings.ToLower(k) == "content-type" {
opts.ContentType = v
} else if strings.ToLower(k) == "cache-control" {
opts.CacheControl = v
} else if strings.ToLower(k) == strings.ToLower(amzWebsiteRedirectLocation) {
opts.WebsiteRedirectLocation = v
} else {
m[k] = metadata[k]
}
}
opts.UserMetadata = m
opts.ServerSideEncryption = sse
return c.putObjectDo(context.Background(), bucket, object, data, md5Base64, sha256Hex, size, opts)
} | [
"func",
"(",
"c",
"Core",
")",
"PutObject",
"(",
"bucket",
",",
"object",
"string",
",",
"data",
"io",
".",
"Reader",
",",
"size",
"int64",
",",
"md5Base64",
",",
"sha256Hex",
"string",
",",
"metadata",
"map",
"[",
"string",
"]",
"string",
",",
"sse",
... | // PutObject - Upload object. Uploads using single PUT call. | [
"PutObject",
"-",
"Upload",
"object",
".",
"Uploads",
"using",
"single",
"PUT",
"call",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L73-L96 | train |
minio/minio-go | core.go | NewMultipartUpload | func (c Core) NewMultipartUpload(bucket, object string, opts PutObjectOptions) (uploadID string, err error) {
result, err := c.initiateMultipartUpload(context.Background(), bucket, object, opts)
return result.UploadID, err
} | go | func (c Core) NewMultipartUpload(bucket, object string, opts PutObjectOptions) (uploadID string, err error) {
result, err := c.initiateMultipartUpload(context.Background(), bucket, object, opts)
return result.UploadID, err
} | [
"func",
"(",
"c",
"Core",
")",
"NewMultipartUpload",
"(",
"bucket",
",",
"object",
"string",
",",
"opts",
"PutObjectOptions",
")",
"(",
"uploadID",
"string",
",",
"err",
"error",
")",
"{",
"result",
",",
"err",
":=",
"c",
".",
"initiateMultipartUpload",
"(... | // NewMultipartUpload - Initiates new multipart upload and returns the new uploadID. | [
"NewMultipartUpload",
"-",
"Initiates",
"new",
"multipart",
"upload",
"and",
"returns",
"the",
"new",
"uploadID",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L99-L102 | train |
minio/minio-go | core.go | ListMultipartUploads | func (c Core) ListMultipartUploads(bucket, prefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (result ListMultipartUploadsResult, err error) {
return c.listMultipartUploadsQuery(bucket, keyMarker, uploadIDMarker, prefix, delimiter, maxUploads)
} | go | func (c Core) ListMultipartUploads(bucket, prefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (result ListMultipartUploadsResult, err error) {
return c.listMultipartUploadsQuery(bucket, keyMarker, uploadIDMarker, prefix, delimiter, maxUploads)
} | [
"func",
"(",
"c",
"Core",
")",
"ListMultipartUploads",
"(",
"bucket",
",",
"prefix",
",",
"keyMarker",
",",
"uploadIDMarker",
",",
"delimiter",
"string",
",",
"maxUploads",
"int",
")",
"(",
"result",
"ListMultipartUploadsResult",
",",
"err",
"error",
")",
"{",... | // ListMultipartUploads - List incomplete uploads. | [
"ListMultipartUploads",
"-",
"List",
"incomplete",
"uploads",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L105-L107 | train |
minio/minio-go | core.go | PutObjectPart | func (c Core) PutObjectPart(bucket, object, uploadID string, partID int, data io.Reader, size int64, md5Base64, sha256Hex string, sse encrypt.ServerSide) (ObjectPart, error) {
return c.uploadPart(context.Background(), bucket, object, uploadID, data, partID, md5Base64, sha256Hex, size, sse)
} | go | func (c Core) PutObjectPart(bucket, object, uploadID string, partID int, data io.Reader, size int64, md5Base64, sha256Hex string, sse encrypt.ServerSide) (ObjectPart, error) {
return c.uploadPart(context.Background(), bucket, object, uploadID, data, partID, md5Base64, sha256Hex, size, sse)
} | [
"func",
"(",
"c",
"Core",
")",
"PutObjectPart",
"(",
"bucket",
",",
"object",
",",
"uploadID",
"string",
",",
"partID",
"int",
",",
"data",
"io",
".",
"Reader",
",",
"size",
"int64",
",",
"md5Base64",
",",
"sha256Hex",
"string",
",",
"sse",
"encrypt",
... | // PutObjectPart - Upload an object part. | [
"PutObjectPart",
"-",
"Upload",
"an",
"object",
"part",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L110-L112 | train |
minio/minio-go | core.go | ListObjectParts | func (c Core) ListObjectParts(bucket, object, uploadID string, partNumberMarker int, maxParts int) (result ListObjectPartsResult, err error) {
return c.listObjectPartsQuery(bucket, object, uploadID, partNumberMarker, maxParts)
} | go | func (c Core) ListObjectParts(bucket, object, uploadID string, partNumberMarker int, maxParts int) (result ListObjectPartsResult, err error) {
return c.listObjectPartsQuery(bucket, object, uploadID, partNumberMarker, maxParts)
} | [
"func",
"(",
"c",
"Core",
")",
"ListObjectParts",
"(",
"bucket",
",",
"object",
",",
"uploadID",
"string",
",",
"partNumberMarker",
"int",
",",
"maxParts",
"int",
")",
"(",
"result",
"ListObjectPartsResult",
",",
"err",
"error",
")",
"{",
"return",
"c",
".... | // ListObjectParts - List uploaded parts of an incomplete upload.x | [
"ListObjectParts",
"-",
"List",
"uploaded",
"parts",
"of",
"an",
"incomplete",
"upload",
".",
"x"
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L115-L117 | train |
minio/minio-go | core.go | CompleteMultipartUpload | func (c Core) CompleteMultipartUpload(bucket, object, uploadID string, parts []CompletePart) (string, error) {
res, err := c.completeMultipartUpload(context.Background(), bucket, object, uploadID, completeMultipartUpload{
Parts: parts,
})
return res.ETag, err
} | go | func (c Core) CompleteMultipartUpload(bucket, object, uploadID string, parts []CompletePart) (string, error) {
res, err := c.completeMultipartUpload(context.Background(), bucket, object, uploadID, completeMultipartUpload{
Parts: parts,
})
return res.ETag, err
} | [
"func",
"(",
"c",
"Core",
")",
"CompleteMultipartUpload",
"(",
"bucket",
",",
"object",
",",
"uploadID",
"string",
",",
"parts",
"[",
"]",
"CompletePart",
")",
"(",
"string",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"c",
".",
"completeMultipartUp... | // CompleteMultipartUpload - Concatenate uploaded parts and commit to an object. | [
"CompleteMultipartUpload",
"-",
"Concatenate",
"uploaded",
"parts",
"and",
"commit",
"to",
"an",
"object",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L120-L125 | train |
minio/minio-go | core.go | AbortMultipartUpload | func (c Core) AbortMultipartUpload(bucket, object, uploadID string) error {
return c.abortMultipartUpload(context.Background(), bucket, object, uploadID)
} | go | func (c Core) AbortMultipartUpload(bucket, object, uploadID string) error {
return c.abortMultipartUpload(context.Background(), bucket, object, uploadID)
} | [
"func",
"(",
"c",
"Core",
")",
"AbortMultipartUpload",
"(",
"bucket",
",",
"object",
",",
"uploadID",
"string",
")",
"error",
"{",
"return",
"c",
".",
"abortMultipartUpload",
"(",
"context",
".",
"Background",
"(",
")",
",",
"bucket",
",",
"object",
",",
... | // AbortMultipartUpload - Abort an incomplete upload. | [
"AbortMultipartUpload",
"-",
"Abort",
"an",
"incomplete",
"upload",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L128-L130 | train |
minio/minio-go | core.go | GetBucketPolicy | func (c Core) GetBucketPolicy(bucket string) (string, error) {
return c.getBucketPolicy(bucket)
} | go | func (c Core) GetBucketPolicy(bucket string) (string, error) {
return c.getBucketPolicy(bucket)
} | [
"func",
"(",
"c",
"Core",
")",
"GetBucketPolicy",
"(",
"bucket",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"c",
".",
"getBucketPolicy",
"(",
"bucket",
")",
"\n",
"}"
] | // GetBucketPolicy - fetches bucket access policy for a given bucket. | [
"GetBucketPolicy",
"-",
"fetches",
"bucket",
"access",
"policy",
"for",
"a",
"given",
"bucket",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L133-L135 | train |
minio/minio-go | core.go | PutBucketPolicy | func (c Core) PutBucketPolicy(bucket, bucketPolicy string) error {
return c.putBucketPolicy(bucket, bucketPolicy)
} | go | func (c Core) PutBucketPolicy(bucket, bucketPolicy string) error {
return c.putBucketPolicy(bucket, bucketPolicy)
} | [
"func",
"(",
"c",
"Core",
")",
"PutBucketPolicy",
"(",
"bucket",
",",
"bucketPolicy",
"string",
")",
"error",
"{",
"return",
"c",
".",
"putBucketPolicy",
"(",
"bucket",
",",
"bucketPolicy",
")",
"\n",
"}"
] | // PutBucketPolicy - applies a new bucket access policy for a given bucket. | [
"PutBucketPolicy",
"-",
"applies",
"a",
"new",
"bucket",
"access",
"policy",
"for",
"a",
"given",
"bucket",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L138-L140 | train |
minio/minio-go | core.go | GetObject | func (c Core) GetObject(bucketName, objectName string, opts GetObjectOptions) (io.ReadCloser, ObjectInfo, error) {
return c.getObject(context.Background(), bucketName, objectName, opts)
} | go | func (c Core) GetObject(bucketName, objectName string, opts GetObjectOptions) (io.ReadCloser, ObjectInfo, error) {
return c.getObject(context.Background(), bucketName, objectName, opts)
} | [
"func",
"(",
"c",
"Core",
")",
"GetObject",
"(",
"bucketName",
",",
"objectName",
"string",
",",
"opts",
"GetObjectOptions",
")",
"(",
"io",
".",
"ReadCloser",
",",
"ObjectInfo",
",",
"error",
")",
"{",
"return",
"c",
".",
"getObject",
"(",
"context",
".... | // GetObject is a lower level API implemented to support reading
// partial objects and also downloading objects with special conditions
// matching etag, modtime etc. | [
"GetObject",
"is",
"a",
"lower",
"level",
"API",
"implemented",
"to",
"support",
"reading",
"partial",
"objects",
"and",
"also",
"downloading",
"objects",
"with",
"special",
"conditions",
"matching",
"etag",
"modtime",
"etc",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L145-L147 | train |
minio/minio-go | core.go | StatObject | func (c Core) StatObject(bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error) {
return c.statObject(context.Background(), bucketName, objectName, opts)
} | go | func (c Core) StatObject(bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error) {
return c.statObject(context.Background(), bucketName, objectName, opts)
} | [
"func",
"(",
"c",
"Core",
")",
"StatObject",
"(",
"bucketName",
",",
"objectName",
"string",
",",
"opts",
"StatObjectOptions",
")",
"(",
"ObjectInfo",
",",
"error",
")",
"{",
"return",
"c",
".",
"statObject",
"(",
"context",
".",
"Background",
"(",
")",
... | // StatObject is a lower level API implemented to support special
// conditions matching etag, modtime on a request. | [
"StatObject",
"is",
"a",
"lower",
"level",
"API",
"implemented",
"to",
"support",
"special",
"conditions",
"matching",
"etag",
"modtime",
"on",
"a",
"request",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/core.go#L151-L153 | train |
minio/minio-go | pkg/credentials/file_aws_credentials.go | NewFileAWSCredentials | func NewFileAWSCredentials(filename string, profile string) *Credentials {
return New(&FileAWSCredentials{
filename: filename,
profile: profile,
})
} | go | func NewFileAWSCredentials(filename string, profile string) *Credentials {
return New(&FileAWSCredentials{
filename: filename,
profile: profile,
})
} | [
"func",
"NewFileAWSCredentials",
"(",
"filename",
"string",
",",
"profile",
"string",
")",
"*",
"Credentials",
"{",
"return",
"New",
"(",
"&",
"FileAWSCredentials",
"{",
"filename",
":",
"filename",
",",
"profile",
":",
"profile",
",",
"}",
")",
"\n",
"}"
] | // NewFileAWSCredentials returns a pointer to a new Credentials object
// wrapping the Profile file provider. | [
"NewFileAWSCredentials",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"Credentials",
"object",
"wrapping",
"the",
"Profile",
"file",
"provider",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/credentials/file_aws_credentials.go#L52-L57 | train |
minio/minio-go | pkg/s3signer/request-signature-v4.go | GetCredential | func GetCredential(accessKeyID, location string, t time.Time) string {
scope := getScope(location, t)
return accessKeyID + "/" + scope
} | go | func GetCredential(accessKeyID, location string, t time.Time) string {
scope := getScope(location, t)
return accessKeyID + "/" + scope
} | [
"func",
"GetCredential",
"(",
"accessKeyID",
",",
"location",
"string",
",",
"t",
"time",
".",
"Time",
")",
"string",
"{",
"scope",
":=",
"getScope",
"(",
"location",
",",
"t",
")",
"\n",
"return",
"accessKeyID",
"+",
"\"",
"\"",
"+",
"scope",
"\n",
"}... | // GetCredential generate a credential string. | [
"GetCredential",
"generate",
"a",
"credential",
"string",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3signer/request-signature-v4.go#L108-L111 | train |
minio/minio-go | pkg/s3signer/request-signature-v4.go | getHashedPayload | func getHashedPayload(req http.Request) string {
hashedPayload := req.Header.Get("X-Amz-Content-Sha256")
if hashedPayload == "" {
// Presign does not have a payload, use S3 recommended value.
hashedPayload = unsignedPayload
}
return hashedPayload
} | go | func getHashedPayload(req http.Request) string {
hashedPayload := req.Header.Get("X-Amz-Content-Sha256")
if hashedPayload == "" {
// Presign does not have a payload, use S3 recommended value.
hashedPayload = unsignedPayload
}
return hashedPayload
} | [
"func",
"getHashedPayload",
"(",
"req",
"http",
".",
"Request",
")",
"string",
"{",
"hashedPayload",
":=",
"req",
".",
"Header",
".",
"Get",
"(",
"\"",
"\"",
")",
"\n",
"if",
"hashedPayload",
"==",
"\"",
"\"",
"{",
"// Presign does not have a payload, use S3 r... | // getHashedPayload get the hexadecimal value of the SHA256 hash of
// the request payload. | [
"getHashedPayload",
"get",
"the",
"hexadecimal",
"value",
"of",
"the",
"SHA256",
"hash",
"of",
"the",
"request",
"payload",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3signer/request-signature-v4.go#L115-L122 | train |
minio/minio-go | pkg/s3signer/request-signature-v4.go | getCanonicalHeaders | func getCanonicalHeaders(req http.Request, ignoredHeaders map[string]bool) string {
var headers []string
vals := make(map[string][]string)
for k, vv := range req.Header {
if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok {
continue // ignored header
}
headers = append(headers, strings.ToLower(k))
vals[strings.ToLower(k)] = vv
}
headers = append(headers, "host")
sort.Strings(headers)
var buf bytes.Buffer
// Save all the headers in canonical form <header>:<value> newline
// separated for each header.
for _, k := range headers {
buf.WriteString(k)
buf.WriteByte(':')
switch {
case k == "host":
buf.WriteString(getHostAddr(&req))
fallthrough
default:
for idx, v := range vals[k] {
if idx > 0 {
buf.WriteByte(',')
}
buf.WriteString(signV4TrimAll(v))
}
buf.WriteByte('\n')
}
}
return buf.String()
} | go | func getCanonicalHeaders(req http.Request, ignoredHeaders map[string]bool) string {
var headers []string
vals := make(map[string][]string)
for k, vv := range req.Header {
if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok {
continue // ignored header
}
headers = append(headers, strings.ToLower(k))
vals[strings.ToLower(k)] = vv
}
headers = append(headers, "host")
sort.Strings(headers)
var buf bytes.Buffer
// Save all the headers in canonical form <header>:<value> newline
// separated for each header.
for _, k := range headers {
buf.WriteString(k)
buf.WriteByte(':')
switch {
case k == "host":
buf.WriteString(getHostAddr(&req))
fallthrough
default:
for idx, v := range vals[k] {
if idx > 0 {
buf.WriteByte(',')
}
buf.WriteString(signV4TrimAll(v))
}
buf.WriteByte('\n')
}
}
return buf.String()
} | [
"func",
"getCanonicalHeaders",
"(",
"req",
"http",
".",
"Request",
",",
"ignoredHeaders",
"map",
"[",
"string",
"]",
"bool",
")",
"string",
"{",
"var",
"headers",
"[",
"]",
"string",
"\n",
"vals",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",... | // getCanonicalHeaders generate a list of request headers for
// signature. | [
"getCanonicalHeaders",
"generate",
"a",
"list",
"of",
"request",
"headers",
"for",
"signature",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3signer/request-signature-v4.go#L126-L160 | train |
minio/minio-go | pkg/s3signer/request-signature-v4.go | getSignedHeaders | func getSignedHeaders(req http.Request, ignoredHeaders map[string]bool) string {
var headers []string
for k := range req.Header {
if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok {
continue // Ignored header found continue.
}
headers = append(headers, strings.ToLower(k))
}
headers = append(headers, "host")
sort.Strings(headers)
return strings.Join(headers, ";")
} | go | func getSignedHeaders(req http.Request, ignoredHeaders map[string]bool) string {
var headers []string
for k := range req.Header {
if _, ok := ignoredHeaders[http.CanonicalHeaderKey(k)]; ok {
continue // Ignored header found continue.
}
headers = append(headers, strings.ToLower(k))
}
headers = append(headers, "host")
sort.Strings(headers)
return strings.Join(headers, ";")
} | [
"func",
"getSignedHeaders",
"(",
"req",
"http",
".",
"Request",
",",
"ignoredHeaders",
"map",
"[",
"string",
"]",
"bool",
")",
"string",
"{",
"var",
"headers",
"[",
"]",
"string",
"\n",
"for",
"k",
":=",
"range",
"req",
".",
"Header",
"{",
"if",
"_",
... | // getSignedHeaders generate all signed request headers.
// i.e lexically sorted, semicolon-separated list of lowercase
// request header names. | [
"getSignedHeaders",
"generate",
"all",
"signed",
"request",
"headers",
".",
"i",
".",
"e",
"lexically",
"sorted",
"semicolon",
"-",
"separated",
"list",
"of",
"lowercase",
"request",
"header",
"names",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3signer/request-signature-v4.go#L165-L176 | train |
minio/minio-go | pkg/s3signer/request-signature-v4.go | PostPresignSignatureV4 | func PostPresignSignatureV4(policyBase64 string, t time.Time, secretAccessKey, location string) string {
// Get signining key.
signingkey := getSigningKey(secretAccessKey, location, t)
// Calculate signature.
signature := getSignature(signingkey, policyBase64)
return signature
} | go | func PostPresignSignatureV4(policyBase64 string, t time.Time, secretAccessKey, location string) string {
// Get signining key.
signingkey := getSigningKey(secretAccessKey, location, t)
// Calculate signature.
signature := getSignature(signingkey, policyBase64)
return signature
} | [
"func",
"PostPresignSignatureV4",
"(",
"policyBase64",
"string",
",",
"t",
"time",
".",
"Time",
",",
"secretAccessKey",
",",
"location",
"string",
")",
"string",
"{",
"// Get signining key.",
"signingkey",
":=",
"getSigningKey",
"(",
"secretAccessKey",
",",
"locatio... | // PostPresignSignatureV4 - presigned signature for PostPolicy
// requests. | [
"PostPresignSignatureV4",
"-",
"presigned",
"signature",
"for",
"PostPolicy",
"requests",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/s3signer/request-signature-v4.go#L258-L264 | train |
minio/minio-go | utils.go | sum256Hex | func sum256Hex(data []byte) string {
hash := sha256.New()
hash.Write(data)
return hex.EncodeToString(hash.Sum(nil))
} | go | func sum256Hex(data []byte) string {
hash := sha256.New()
hash.Write(data)
return hex.EncodeToString(hash.Sum(nil))
} | [
"func",
"sum256Hex",
"(",
"data",
"[",
"]",
"byte",
")",
"string",
"{",
"hash",
":=",
"sha256",
".",
"New",
"(",
")",
"\n",
"hash",
".",
"Write",
"(",
"data",
")",
"\n",
"return",
"hex",
".",
"EncodeToString",
"(",
"hash",
".",
"Sum",
"(",
"nil",
... | // sum256 calculate sha256sum for an input byte array, returns hex encoded. | [
"sum256",
"calculate",
"sha256sum",
"for",
"an",
"input",
"byte",
"array",
"returns",
"hex",
"encoded",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L45-L49 | train |
minio/minio-go | utils.go | sumMD5Base64 | func sumMD5Base64(data []byte) string {
hash := md5.New()
hash.Write(data)
return base64.StdEncoding.EncodeToString(hash.Sum(nil))
} | go | func sumMD5Base64(data []byte) string {
hash := md5.New()
hash.Write(data)
return base64.StdEncoding.EncodeToString(hash.Sum(nil))
} | [
"func",
"sumMD5Base64",
"(",
"data",
"[",
"]",
"byte",
")",
"string",
"{",
"hash",
":=",
"md5",
".",
"New",
"(",
")",
"\n",
"hash",
".",
"Write",
"(",
"data",
")",
"\n",
"return",
"base64",
".",
"StdEncoding",
".",
"EncodeToString",
"(",
"hash",
".",... | // sumMD5Base64 calculate md5sum for an input byte array, returns base64 encoded. | [
"sumMD5Base64",
"calculate",
"md5sum",
"for",
"an",
"input",
"byte",
"array",
"returns",
"base64",
"encoded",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L52-L56 | train |
minio/minio-go | utils.go | getEndpointURL | func getEndpointURL(endpoint string, secure bool) (*url.URL, error) {
if strings.Contains(endpoint, ":") {
host, _, err := net.SplitHostPort(endpoint)
if err != nil {
return nil, err
}
if !s3utils.IsValidIP(host) && !s3utils.IsValidDomain(host) {
msg := "Endpoint: " + endpoint + " does not follow ip address or domain name standards."
return nil, ErrInvalidArgument(msg)
}
} else {
if !s3utils.IsValidIP(endpoint) && !s3utils.IsValidDomain(endpoint) {
msg := "Endpoint: " + endpoint + " does not follow ip address or domain name standards."
return nil, ErrInvalidArgument(msg)
}
}
// If secure is false, use 'http' scheme.
scheme := "https"
if !secure {
scheme = "http"
}
// Construct a secured endpoint URL.
endpointURLStr := scheme + "://" + endpoint
endpointURL, err := url.Parse(endpointURLStr)
if err != nil {
return nil, err
}
// Validate incoming endpoint URL.
if err := isValidEndpointURL(*endpointURL); err != nil {
return nil, err
}
return endpointURL, nil
} | go | func getEndpointURL(endpoint string, secure bool) (*url.URL, error) {
if strings.Contains(endpoint, ":") {
host, _, err := net.SplitHostPort(endpoint)
if err != nil {
return nil, err
}
if !s3utils.IsValidIP(host) && !s3utils.IsValidDomain(host) {
msg := "Endpoint: " + endpoint + " does not follow ip address or domain name standards."
return nil, ErrInvalidArgument(msg)
}
} else {
if !s3utils.IsValidIP(endpoint) && !s3utils.IsValidDomain(endpoint) {
msg := "Endpoint: " + endpoint + " does not follow ip address or domain name standards."
return nil, ErrInvalidArgument(msg)
}
}
// If secure is false, use 'http' scheme.
scheme := "https"
if !secure {
scheme = "http"
}
// Construct a secured endpoint URL.
endpointURLStr := scheme + "://" + endpoint
endpointURL, err := url.Parse(endpointURLStr)
if err != nil {
return nil, err
}
// Validate incoming endpoint URL.
if err := isValidEndpointURL(*endpointURL); err != nil {
return nil, err
}
return endpointURL, nil
} | [
"func",
"getEndpointURL",
"(",
"endpoint",
"string",
",",
"secure",
"bool",
")",
"(",
"*",
"url",
".",
"URL",
",",
"error",
")",
"{",
"if",
"strings",
".",
"Contains",
"(",
"endpoint",
",",
"\"",
"\"",
")",
"{",
"host",
",",
"_",
",",
"err",
":=",
... | // getEndpointURL - construct a new endpoint. | [
"getEndpointURL",
"-",
"construct",
"a",
"new",
"endpoint",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L59-L93 | train |
minio/minio-go | utils.go | isValidExpiry | func isValidExpiry(expires time.Duration) error {
expireSeconds := int64(expires / time.Second)
if expireSeconds < 1 {
return ErrInvalidArgument("Expires cannot be lesser than 1 second.")
}
if expireSeconds > 604800 {
return ErrInvalidArgument("Expires cannot be greater than 7 days.")
}
return nil
} | go | func isValidExpiry(expires time.Duration) error {
expireSeconds := int64(expires / time.Second)
if expireSeconds < 1 {
return ErrInvalidArgument("Expires cannot be lesser than 1 second.")
}
if expireSeconds > 604800 {
return ErrInvalidArgument("Expires cannot be greater than 7 days.")
}
return nil
} | [
"func",
"isValidExpiry",
"(",
"expires",
"time",
".",
"Duration",
")",
"error",
"{",
"expireSeconds",
":=",
"int64",
"(",
"expires",
"/",
"time",
".",
"Second",
")",
"\n",
"if",
"expireSeconds",
"<",
"1",
"{",
"return",
"ErrInvalidArgument",
"(",
"\"",
"\"... | // Verify if input expires value is valid. | [
"Verify",
"if",
"input",
"expires",
"value",
"is",
"valid",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L145-L154 | train |
minio/minio-go | utils.go | cloneHeader | func cloneHeader(h http.Header) http.Header {
h2 := make(http.Header, len(h))
for k, vv := range h {
vv2 := make([]string, len(vv))
copy(vv2, vv)
h2[k] = vv2
}
return h2
} | go | func cloneHeader(h http.Header) http.Header {
h2 := make(http.Header, len(h))
for k, vv := range h {
vv2 := make([]string, len(vv))
copy(vv2, vv)
h2[k] = vv2
}
return h2
} | [
"func",
"cloneHeader",
"(",
"h",
"http",
".",
"Header",
")",
"http",
".",
"Header",
"{",
"h2",
":=",
"make",
"(",
"http",
".",
"Header",
",",
"len",
"(",
"h",
")",
")",
"\n",
"for",
"k",
",",
"vv",
":=",
"range",
"h",
"{",
"vv2",
":=",
"make",
... | // make a copy of http.Header | [
"make",
"a",
"copy",
"of",
"http",
".",
"Header"
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L157-L165 | train |
minio/minio-go | utils.go | filterHeader | func filterHeader(header http.Header, filterKeys []string) (filteredHeader http.Header) {
filteredHeader = cloneHeader(header)
for _, key := range filterKeys {
filteredHeader.Del(key)
}
return filteredHeader
} | go | func filterHeader(header http.Header, filterKeys []string) (filteredHeader http.Header) {
filteredHeader = cloneHeader(header)
for _, key := range filterKeys {
filteredHeader.Del(key)
}
return filteredHeader
} | [
"func",
"filterHeader",
"(",
"header",
"http",
".",
"Header",
",",
"filterKeys",
"[",
"]",
"string",
")",
"(",
"filteredHeader",
"http",
".",
"Header",
")",
"{",
"filteredHeader",
"=",
"cloneHeader",
"(",
"header",
")",
"\n",
"for",
"_",
",",
"key",
":="... | // Filter relevant response headers from
// the HEAD, GET http response. The function takes
// a list of headers which are filtered out and
// returned as a new http header. | [
"Filter",
"relevant",
"response",
"headers",
"from",
"the",
"HEAD",
"GET",
"http",
"response",
".",
"The",
"function",
"takes",
"a",
"list",
"of",
"headers",
"which",
"are",
"filtered",
"out",
"and",
"returned",
"as",
"a",
"new",
"http",
"header",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L171-L177 | train |
minio/minio-go | utils.go | redactSignature | func redactSignature(origAuth string) string {
if !strings.HasPrefix(origAuth, signV4Algorithm) {
// Set a temporary redacted auth
return "AWS **REDACTED**:**REDACTED**"
}
/// Signature V4 authorization header.
// Strip out accessKeyID from:
// Credential=<access-key-id>/<date>/<aws-region>/<aws-service>/aws4_request
newAuth := regCred.ReplaceAllString(origAuth, "Credential=**REDACTED**/")
// Strip out 256-bit signature from: Signature=<256-bit signature>
return regSign.ReplaceAllString(newAuth, "Signature=**REDACTED**")
} | go | func redactSignature(origAuth string) string {
if !strings.HasPrefix(origAuth, signV4Algorithm) {
// Set a temporary redacted auth
return "AWS **REDACTED**:**REDACTED**"
}
/// Signature V4 authorization header.
// Strip out accessKeyID from:
// Credential=<access-key-id>/<date>/<aws-region>/<aws-service>/aws4_request
newAuth := regCred.ReplaceAllString(origAuth, "Credential=**REDACTED**/")
// Strip out 256-bit signature from: Signature=<256-bit signature>
return regSign.ReplaceAllString(newAuth, "Signature=**REDACTED**")
} | [
"func",
"redactSignature",
"(",
"origAuth",
"string",
")",
"string",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"origAuth",
",",
"signV4Algorithm",
")",
"{",
"// Set a temporary redacted auth",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"/// Signature V4 auth... | // Redact out signature value from authorization string. | [
"Redact",
"out",
"signature",
"value",
"from",
"authorization",
"string",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L186-L200 | train |
minio/minio-go | utils.go | getDefaultLocation | func getDefaultLocation(u url.URL, regionOverride string) (location string) {
if regionOverride != "" {
return regionOverride
}
region := s3utils.GetRegionFromURL(u)
if region == "" {
region = "us-east-1"
}
return region
} | go | func getDefaultLocation(u url.URL, regionOverride string) (location string) {
if regionOverride != "" {
return regionOverride
}
region := s3utils.GetRegionFromURL(u)
if region == "" {
region = "us-east-1"
}
return region
} | [
"func",
"getDefaultLocation",
"(",
"u",
"url",
".",
"URL",
",",
"regionOverride",
"string",
")",
"(",
"location",
"string",
")",
"{",
"if",
"regionOverride",
"!=",
"\"",
"\"",
"{",
"return",
"regionOverride",
"\n",
"}",
"\n",
"region",
":=",
"s3utils",
"."... | // Get default location returns the location based on the input
// URL `u`, if region override is provided then all location
// defaults to regionOverride.
//
// If no other cases match then the location is set to `us-east-1`
// as a last resort. | [
"Get",
"default",
"location",
"returns",
"the",
"location",
"based",
"on",
"the",
"input",
"URL",
"u",
"if",
"region",
"override",
"is",
"provided",
"then",
"all",
"location",
"defaults",
"to",
"regionOverride",
".",
"If",
"no",
"other",
"cases",
"match",
"t... | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L208-L217 | train |
minio/minio-go | utils.go | isStorageClassHeader | func isStorageClassHeader(headerKey string) bool {
return strings.ToLower(amzStorageClass) == strings.ToLower(headerKey)
} | go | func isStorageClassHeader(headerKey string) bool {
return strings.ToLower(amzStorageClass) == strings.ToLower(headerKey)
} | [
"func",
"isStorageClassHeader",
"(",
"headerKey",
"string",
")",
"bool",
"{",
"return",
"strings",
".",
"ToLower",
"(",
"amzStorageClass",
")",
"==",
"strings",
".",
"ToLower",
"(",
"headerKey",
")",
"\n",
"}"
] | // isStorageClassHeader returns true if the header is a supported storage class header | [
"isStorageClassHeader",
"returns",
"true",
"if",
"the",
"header",
"is",
"a",
"supported",
"storage",
"class",
"header"
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L231-L233 | train |
minio/minio-go | utils.go | isStandardHeader | func isStandardHeader(headerKey string) bool {
key := strings.ToLower(headerKey)
for _, header := range supportedHeaders {
if strings.ToLower(header) == key {
return true
}
}
return false
} | go | func isStandardHeader(headerKey string) bool {
key := strings.ToLower(headerKey)
for _, header := range supportedHeaders {
if strings.ToLower(header) == key {
return true
}
}
return false
} | [
"func",
"isStandardHeader",
"(",
"headerKey",
"string",
")",
"bool",
"{",
"key",
":=",
"strings",
".",
"ToLower",
"(",
"headerKey",
")",
"\n",
"for",
"_",
",",
"header",
":=",
"range",
"supportedHeaders",
"{",
"if",
"strings",
".",
"ToLower",
"(",
"header"... | // isStandardHeader returns true if header is a supported header and not a custom header | [
"isStandardHeader",
"returns",
"true",
"if",
"header",
"is",
"a",
"supported",
"header",
"and",
"not",
"a",
"custom",
"header"
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L236-L244 | train |
minio/minio-go | utils.go | isSSEHeader | func isSSEHeader(headerKey string) bool {
key := strings.ToLower(headerKey)
for _, h := range sseHeaders {
if strings.ToLower(h) == key {
return true
}
}
return false
} | go | func isSSEHeader(headerKey string) bool {
key := strings.ToLower(headerKey)
for _, h := range sseHeaders {
if strings.ToLower(h) == key {
return true
}
}
return false
} | [
"func",
"isSSEHeader",
"(",
"headerKey",
"string",
")",
"bool",
"{",
"key",
":=",
"strings",
".",
"ToLower",
"(",
"headerKey",
")",
"\n",
"for",
"_",
",",
"h",
":=",
"range",
"sseHeaders",
"{",
"if",
"strings",
".",
"ToLower",
"(",
"h",
")",
"==",
"k... | // isSSEHeader returns true if header is a server side encryption header. | [
"isSSEHeader",
"returns",
"true",
"if",
"header",
"is",
"a",
"server",
"side",
"encryption",
"header",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/utils.go#L257-L265 | train |
minio/minio-go | pkg/credentials/file_minio_client.go | NewFileMinioClient | func NewFileMinioClient(filename string, alias string) *Credentials {
return New(&FileMinioClient{
filename: filename,
alias: alias,
})
} | go | func NewFileMinioClient(filename string, alias string) *Credentials {
return New(&FileMinioClient{
filename: filename,
alias: alias,
})
} | [
"func",
"NewFileMinioClient",
"(",
"filename",
"string",
",",
"alias",
"string",
")",
"*",
"Credentials",
"{",
"return",
"New",
"(",
"&",
"FileMinioClient",
"{",
"filename",
":",
"filename",
",",
"alias",
":",
"alias",
",",
"}",
")",
"\n",
"}"
] | // NewFileMinioClient returns a pointer to a new Credentials object
// wrapping the Alias file provider. | [
"NewFileMinioClient",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"Credentials",
"object",
"wrapping",
"the",
"Alias",
"file",
"provider",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/credentials/file_minio_client.go#L54-L59 | train |
minio/minio-go | pkg/credentials/file_minio_client.go | loadAlias | func loadAlias(filename, alias string) (hostConfig, error) {
cfg := &config{}
configBytes, err := ioutil.ReadFile(filename)
if err != nil {
return hostConfig{}, err
}
if err = json.Unmarshal(configBytes, cfg); err != nil {
return hostConfig{}, err
}
return cfg.Hosts[alias], nil
} | go | func loadAlias(filename, alias string) (hostConfig, error) {
cfg := &config{}
configBytes, err := ioutil.ReadFile(filename)
if err != nil {
return hostConfig{}, err
}
if err = json.Unmarshal(configBytes, cfg); err != nil {
return hostConfig{}, err
}
return cfg.Hosts[alias], nil
} | [
"func",
"loadAlias",
"(",
"filename",
",",
"alias",
"string",
")",
"(",
"hostConfig",
",",
"error",
")",
"{",
"cfg",
":=",
"&",
"config",
"{",
"}",
"\n",
"configBytes",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"filename",
")",
"\n",
"if",
"e... | // loadAliass loads from the file pointed to by shared credentials filename for alias.
// The credentials retrieved from the alias will be returned or error. Error will be
// returned if it fails to read from the file. | [
"loadAliass",
"loads",
"from",
"the",
"file",
"pointed",
"to",
"by",
"shared",
"credentials",
"filename",
"for",
"alias",
".",
"The",
"credentials",
"retrieved",
"from",
"the",
"alias",
"will",
"be",
"returned",
"or",
"error",
".",
"Error",
"will",
"be",
"re... | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/credentials/file_minio_client.go#L123-L133 | train |
minio/minio-go | api-get-object-acl.go | GetObjectACL | func (c Client) GetObjectACL(bucketName, objectName string) (*ObjectInfo, error) {
resp, err := c.executeMethod(context.Background(), "GET", requestMetadata{
bucketName: bucketName,
objectName: objectName,
queryValues: url.Values{
"acl": []string{""},
},
})
if err != nil {
return nil, err
}
defer closeResponse(resp)
if resp.StatusCode != http.StatusOK {
return nil, httpRespToErrorResponse(resp, bucketName, objectName)
}
res := &accessControlPolicy{}
if err := xmlDecoder(resp.Body, res); err != nil {
return nil, err
}
objInfo, err := c.statObject(context.Background(), bucketName, objectName, StatObjectOptions{})
if err != nil {
return nil, err
}
cannedACL := getCannedACL(res)
if cannedACL != "" {
objInfo.Metadata.Add("X-Amz-Acl", cannedACL)
return &objInfo, nil
}
grantACL := getAmzGrantACL(res)
for k, v := range grantACL {
objInfo.Metadata[k] = v
}
return &objInfo, nil
} | go | func (c Client) GetObjectACL(bucketName, objectName string) (*ObjectInfo, error) {
resp, err := c.executeMethod(context.Background(), "GET", requestMetadata{
bucketName: bucketName,
objectName: objectName,
queryValues: url.Values{
"acl": []string{""},
},
})
if err != nil {
return nil, err
}
defer closeResponse(resp)
if resp.StatusCode != http.StatusOK {
return nil, httpRespToErrorResponse(resp, bucketName, objectName)
}
res := &accessControlPolicy{}
if err := xmlDecoder(resp.Body, res); err != nil {
return nil, err
}
objInfo, err := c.statObject(context.Background(), bucketName, objectName, StatObjectOptions{})
if err != nil {
return nil, err
}
cannedACL := getCannedACL(res)
if cannedACL != "" {
objInfo.Metadata.Add("X-Amz-Acl", cannedACL)
return &objInfo, nil
}
grantACL := getAmzGrantACL(res)
for k, v := range grantACL {
objInfo.Metadata[k] = v
}
return &objInfo, nil
} | [
"func",
"(",
"c",
"Client",
")",
"GetObjectACL",
"(",
"bucketName",
",",
"objectName",
"string",
")",
"(",
"*",
"ObjectInfo",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"c",
".",
"executeMethod",
"(",
"context",
".",
"Background",
"(",
")",
",",... | //GetObjectACL get object ACLs | [
"GetObjectACL",
"get",
"object",
"ACLs"
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-get-object-acl.go#L44-L85 | train |
minio/minio-go | api-compose-object.go | SetRange | func (s *SourceInfo) SetRange(start, end int64) error {
if start > end || start < 0 {
return ErrInvalidArgument("start must be non-negative, and start must be at most end.")
}
// Note that 0 <= start <= end
s.start, s.end = start, end
return nil
} | go | func (s *SourceInfo) SetRange(start, end int64) error {
if start > end || start < 0 {
return ErrInvalidArgument("start must be non-negative, and start must be at most end.")
}
// Note that 0 <= start <= end
s.start, s.end = start, end
return nil
} | [
"func",
"(",
"s",
"*",
"SourceInfo",
")",
"SetRange",
"(",
"start",
",",
"end",
"int64",
")",
"error",
"{",
"if",
"start",
">",
"end",
"||",
"start",
"<",
"0",
"{",
"return",
"ErrInvalidArgument",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"// Note that ... | // SetRange - Set the start and end offset of the source object to be
// copied. If this method is not called, the whole source object is
// copied. | [
"SetRange",
"-",
"Set",
"the",
"start",
"and",
"end",
"offset",
"of",
"the",
"source",
"object",
"to",
"be",
"copied",
".",
"If",
"this",
"method",
"is",
"not",
"called",
"the",
"whole",
"source",
"object",
"is",
"copied",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-compose-object.go#L147-L154 | train |
minio/minio-go | api-compose-object.go | SetMatchETagCond | func (s *SourceInfo) SetMatchETagCond(etag string) error {
if etag == "" {
return ErrInvalidArgument("ETag cannot be empty.")
}
s.Headers.Set("x-amz-copy-source-if-match", etag)
return nil
} | go | func (s *SourceInfo) SetMatchETagCond(etag string) error {
if etag == "" {
return ErrInvalidArgument("ETag cannot be empty.")
}
s.Headers.Set("x-amz-copy-source-if-match", etag)
return nil
} | [
"func",
"(",
"s",
"*",
"SourceInfo",
")",
"SetMatchETagCond",
"(",
"etag",
"string",
")",
"error",
"{",
"if",
"etag",
"==",
"\"",
"\"",
"{",
"return",
"ErrInvalidArgument",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"s",
".",
"Headers",
".",
"Set",
"(",
... | // SetMatchETagCond - Set ETag match condition. The object is copied
// only if the etag of the source matches the value given here. | [
"SetMatchETagCond",
"-",
"Set",
"ETag",
"match",
"condition",
".",
"The",
"object",
"is",
"copied",
"only",
"if",
"the",
"etag",
"of",
"the",
"source",
"matches",
"the",
"value",
"given",
"here",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-compose-object.go#L158-L164 | train |
minio/minio-go | api-compose-object.go | SetModifiedSinceCond | func (s *SourceInfo) SetModifiedSinceCond(modTime time.Time) error {
if modTime.IsZero() {
return ErrInvalidArgument("Input time cannot be 0.")
}
s.Headers.Set("x-amz-copy-source-if-modified-since", modTime.Format(http.TimeFormat))
return nil
} | go | func (s *SourceInfo) SetModifiedSinceCond(modTime time.Time) error {
if modTime.IsZero() {
return ErrInvalidArgument("Input time cannot be 0.")
}
s.Headers.Set("x-amz-copy-source-if-modified-since", modTime.Format(http.TimeFormat))
return nil
} | [
"func",
"(",
"s",
"*",
"SourceInfo",
")",
"SetModifiedSinceCond",
"(",
"modTime",
"time",
".",
"Time",
")",
"error",
"{",
"if",
"modTime",
".",
"IsZero",
"(",
")",
"{",
"return",
"ErrInvalidArgument",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"s",
".",
... | // SetModifiedSinceCond - Set the modified since condition. | [
"SetModifiedSinceCond",
"-",
"Set",
"the",
"modified",
"since",
"condition",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-compose-object.go#L178-L184 | train |
minio/minio-go | api-compose-object.go | getProps | func (s *SourceInfo) getProps(c Client) (size int64, etag string, userMeta map[string]string, err error) {
// Get object info - need size and etag here. Also, decryption
// headers are added to the stat request if given.
var objInfo ObjectInfo
opts := StatObjectOptions{GetObjectOptions{ServerSideEncryption: encrypt.SSE(s.encryption)}}
objInfo, err = c.statObject(context.Background(), s.bucket, s.object, opts)
if err != nil {
err = ErrInvalidArgument(fmt.Sprintf("Could not stat object - %s/%s: %v", s.bucket, s.object, err))
} else {
size = objInfo.Size
etag = objInfo.ETag
userMeta = make(map[string]string)
for k, v := range objInfo.Metadata {
if strings.HasPrefix(k, "x-amz-meta-") {
if len(v) > 0 {
userMeta[k] = v[0]
}
}
}
}
return
} | go | func (s *SourceInfo) getProps(c Client) (size int64, etag string, userMeta map[string]string, err error) {
// Get object info - need size and etag here. Also, decryption
// headers are added to the stat request if given.
var objInfo ObjectInfo
opts := StatObjectOptions{GetObjectOptions{ServerSideEncryption: encrypt.SSE(s.encryption)}}
objInfo, err = c.statObject(context.Background(), s.bucket, s.object, opts)
if err != nil {
err = ErrInvalidArgument(fmt.Sprintf("Could not stat object - %s/%s: %v", s.bucket, s.object, err))
} else {
size = objInfo.Size
etag = objInfo.ETag
userMeta = make(map[string]string)
for k, v := range objInfo.Metadata {
if strings.HasPrefix(k, "x-amz-meta-") {
if len(v) > 0 {
userMeta[k] = v[0]
}
}
}
}
return
} | [
"func",
"(",
"s",
"*",
"SourceInfo",
")",
"getProps",
"(",
"c",
"Client",
")",
"(",
"size",
"int64",
",",
"etag",
"string",
",",
"userMeta",
"map",
"[",
"string",
"]",
"string",
",",
"err",
"error",
")",
"{",
"// Get object info - need size and etag here. Al... | // Helper to fetch size and etag of an object using a StatObject call. | [
"Helper",
"to",
"fetch",
"size",
"and",
"etag",
"of",
"an",
"object",
"using",
"a",
"StatObject",
"call",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-compose-object.go#L196-L217 | train |
minio/minio-go | api-compose-object.go | copyObjectDo | func (c Client) copyObjectDo(ctx context.Context, srcBucket, srcObject, destBucket, destObject string,
metadata map[string]string) (ObjectInfo, error) {
// Build headers.
headers := make(http.Header)
// Set all the metadata headers.
for k, v := range metadata {
headers.Set(k, v)
}
// Set the source header
headers.Set("x-amz-copy-source", s3utils.EncodePath(srcBucket+"/"+srcObject))
// Send upload-part-copy request
resp, err := c.executeMethod(ctx, "PUT", requestMetadata{
bucketName: destBucket,
objectName: destObject,
customHeader: headers,
})
defer closeResponse(resp)
if err != nil {
return ObjectInfo{}, err
}
// Check if we got an error response.
if resp.StatusCode != http.StatusOK {
return ObjectInfo{}, httpRespToErrorResponse(resp, srcBucket, srcObject)
}
cpObjRes := copyObjectResult{}
err = xmlDecoder(resp.Body, &cpObjRes)
if err != nil {
return ObjectInfo{}, err
}
objInfo := ObjectInfo{
Key: destObject,
ETag: strings.Trim(cpObjRes.ETag, "\""),
LastModified: cpObjRes.LastModified,
}
return objInfo, nil
} | go | func (c Client) copyObjectDo(ctx context.Context, srcBucket, srcObject, destBucket, destObject string,
metadata map[string]string) (ObjectInfo, error) {
// Build headers.
headers := make(http.Header)
// Set all the metadata headers.
for k, v := range metadata {
headers.Set(k, v)
}
// Set the source header
headers.Set("x-amz-copy-source", s3utils.EncodePath(srcBucket+"/"+srcObject))
// Send upload-part-copy request
resp, err := c.executeMethod(ctx, "PUT", requestMetadata{
bucketName: destBucket,
objectName: destObject,
customHeader: headers,
})
defer closeResponse(resp)
if err != nil {
return ObjectInfo{}, err
}
// Check if we got an error response.
if resp.StatusCode != http.StatusOK {
return ObjectInfo{}, httpRespToErrorResponse(resp, srcBucket, srcObject)
}
cpObjRes := copyObjectResult{}
err = xmlDecoder(resp.Body, &cpObjRes)
if err != nil {
return ObjectInfo{}, err
}
objInfo := ObjectInfo{
Key: destObject,
ETag: strings.Trim(cpObjRes.ETag, "\""),
LastModified: cpObjRes.LastModified,
}
return objInfo, nil
} | [
"func",
"(",
"c",
"Client",
")",
"copyObjectDo",
"(",
"ctx",
"context",
".",
"Context",
",",
"srcBucket",
",",
"srcObject",
",",
"destBucket",
",",
"destObject",
"string",
",",
"metadata",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"ObjectInfo",
",",
... | // Low level implementation of CopyObject API, supports only upto 5GiB worth of copy. | [
"Low",
"level",
"implementation",
"of",
"CopyObject",
"API",
"supports",
"only",
"upto",
"5GiB",
"worth",
"of",
"copy",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-compose-object.go#L220-L262 | train |
minio/minio-go | api-compose-object.go | calculateEvenSplits | func calculateEvenSplits(size int64, src SourceInfo) (startIndex, endIndex []int64) {
if size == 0 {
return
}
reqParts := partsRequired(size)
startIndex = make([]int64, reqParts)
endIndex = make([]int64, reqParts)
// Compute number of required parts `k`, as:
//
// k = ceiling(size / copyPartSize)
//
// Now, distribute the `size` bytes in the source into
// k parts as evenly as possible:
//
// r parts sized (q+1) bytes, and
// (k - r) parts sized q bytes, where
//
// size = q * k + r (by simple division of size by k,
// so that 0 <= r < k)
//
start := src.start
if start == -1 {
start = 0
}
quot, rem := size/reqParts, size%reqParts
nextStart := start
for j := int64(0); j < reqParts; j++ {
curPartSize := quot
if j < rem {
curPartSize++
}
cStart := nextStart
cEnd := cStart + curPartSize - 1
nextStart = cEnd + 1
startIndex[j], endIndex[j] = cStart, cEnd
}
return
} | go | func calculateEvenSplits(size int64, src SourceInfo) (startIndex, endIndex []int64) {
if size == 0 {
return
}
reqParts := partsRequired(size)
startIndex = make([]int64, reqParts)
endIndex = make([]int64, reqParts)
// Compute number of required parts `k`, as:
//
// k = ceiling(size / copyPartSize)
//
// Now, distribute the `size` bytes in the source into
// k parts as evenly as possible:
//
// r parts sized (q+1) bytes, and
// (k - r) parts sized q bytes, where
//
// size = q * k + r (by simple division of size by k,
// so that 0 <= r < k)
//
start := src.start
if start == -1 {
start = 0
}
quot, rem := size/reqParts, size%reqParts
nextStart := start
for j := int64(0); j < reqParts; j++ {
curPartSize := quot
if j < rem {
curPartSize++
}
cStart := nextStart
cEnd := cStart + curPartSize - 1
nextStart = cEnd + 1
startIndex[j], endIndex[j] = cStart, cEnd
}
return
} | [
"func",
"calculateEvenSplits",
"(",
"size",
"int64",
",",
"src",
"SourceInfo",
")",
"(",
"startIndex",
",",
"endIndex",
"[",
"]",
"int64",
")",
"{",
"if",
"size",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"reqParts",
":=",
"partsRequired",
"(",
"size"... | // calculateEvenSplits - computes splits for a source and returns
// start and end index slices. Splits happen evenly to be sure that no
// part is less than 5MiB, as that could fail the multipart request if
// it is not the last part. | [
"calculateEvenSplits",
"-",
"computes",
"splits",
"for",
"a",
"source",
"and",
"returns",
"start",
"and",
"end",
"index",
"slices",
".",
"Splits",
"happen",
"evenly",
"to",
"be",
"sure",
"that",
"no",
"part",
"is",
"less",
"than",
"5MiB",
"as",
"that",
"co... | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-compose-object.go#L525-L565 | train |
minio/minio-go | pkg/set/stringset.go | ToSlice | func (set StringSet) ToSlice() []string {
keys := make([]string, 0, len(set))
for k := range set {
keys = append(keys, k)
}
sort.Strings(keys)
return keys
} | go | func (set StringSet) ToSlice() []string {
keys := make([]string, 0, len(set))
for k := range set {
keys = append(keys, k)
}
sort.Strings(keys)
return keys
} | [
"func",
"(",
"set",
"StringSet",
")",
"ToSlice",
"(",
")",
"[",
"]",
"string",
"{",
"keys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"set",
")",
")",
"\n",
"for",
"k",
":=",
"range",
"set",
"{",
"keys",
"=",
"append",
... | // ToSlice - returns StringSet as string slice. | [
"ToSlice",
"-",
"returns",
"StringSet",
"as",
"string",
"slice",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L30-L37 | train |
minio/minio-go | pkg/set/stringset.go | Contains | func (set StringSet) Contains(s string) bool {
_, ok := set[s]
return ok
} | go | func (set StringSet) Contains(s string) bool {
_, ok := set[s]
return ok
} | [
"func",
"(",
"set",
"StringSet",
")",
"Contains",
"(",
"s",
"string",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"set",
"[",
"s",
"]",
"\n",
"return",
"ok",
"\n",
"}"
] | // Contains - checks if string is in the set. | [
"Contains",
"-",
"checks",
"if",
"string",
"is",
"in",
"the",
"set",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L55-L58 | train |
minio/minio-go | pkg/set/stringset.go | FuncMatch | func (set StringSet) FuncMatch(matchFn func(string, string) bool, matchString string) StringSet {
nset := NewStringSet()
for k := range set {
if matchFn(k, matchString) {
nset.Add(k)
}
}
return nset
} | go | func (set StringSet) FuncMatch(matchFn func(string, string) bool, matchString string) StringSet {
nset := NewStringSet()
for k := range set {
if matchFn(k, matchString) {
nset.Add(k)
}
}
return nset
} | [
"func",
"(",
"set",
"StringSet",
")",
"FuncMatch",
"(",
"matchFn",
"func",
"(",
"string",
",",
"string",
")",
"bool",
",",
"matchString",
"string",
")",
"StringSet",
"{",
"nset",
":=",
"NewStringSet",
"(",
")",
"\n",
"for",
"k",
":=",
"range",
"set",
"... | // FuncMatch - returns new set containing each value who passes match function.
// A 'matchFn' should accept element in a set as first argument and
// 'matchString' as second argument. The function can do any logic to
// compare both the arguments and should return true to accept element in
// a set to include in output set else the element is ignored. | [
"FuncMatch",
"-",
"returns",
"new",
"set",
"containing",
"each",
"value",
"who",
"passes",
"match",
"function",
".",
"A",
"matchFn",
"should",
"accept",
"element",
"in",
"a",
"set",
"as",
"first",
"argument",
"and",
"matchString",
"as",
"second",
"argument",
... | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L65-L73 | train |
minio/minio-go | pkg/set/stringset.go | ApplyFunc | func (set StringSet) ApplyFunc(applyFn func(string) string) StringSet {
nset := NewStringSet()
for k := range set {
nset.Add(applyFn(k))
}
return nset
} | go | func (set StringSet) ApplyFunc(applyFn func(string) string) StringSet {
nset := NewStringSet()
for k := range set {
nset.Add(applyFn(k))
}
return nset
} | [
"func",
"(",
"set",
"StringSet",
")",
"ApplyFunc",
"(",
"applyFn",
"func",
"(",
"string",
")",
"string",
")",
"StringSet",
"{",
"nset",
":=",
"NewStringSet",
"(",
")",
"\n",
"for",
"k",
":=",
"range",
"set",
"{",
"nset",
".",
"Add",
"(",
"applyFn",
"... | // ApplyFunc - returns new set containing each value processed by 'applyFn'.
// A 'applyFn' should accept element in a set as a argument and return
// a processed string. The function can do any logic to return a processed
// string. | [
"ApplyFunc",
"-",
"returns",
"new",
"set",
"containing",
"each",
"value",
"processed",
"by",
"applyFn",
".",
"A",
"applyFn",
"should",
"accept",
"element",
"in",
"a",
"set",
"as",
"a",
"argument",
"and",
"return",
"a",
"processed",
"string",
".",
"The",
"f... | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L79-L85 | train |
minio/minio-go | pkg/set/stringset.go | Equals | func (set StringSet) Equals(sset StringSet) bool {
// If length of set is not equal to length of given set, the
// set is not equal to given set.
if len(set) != len(sset) {
return false
}
// As both sets are equal in length, check each elements are equal.
for k := range set {
if _, ok := sset[k]; !ok {
return false
}
}
return true
} | go | func (set StringSet) Equals(sset StringSet) bool {
// If length of set is not equal to length of given set, the
// set is not equal to given set.
if len(set) != len(sset) {
return false
}
// As both sets are equal in length, check each elements are equal.
for k := range set {
if _, ok := sset[k]; !ok {
return false
}
}
return true
} | [
"func",
"(",
"set",
"StringSet",
")",
"Equals",
"(",
"sset",
"StringSet",
")",
"bool",
"{",
"// If length of set is not equal to length of given set, the",
"// set is not equal to given set.",
"if",
"len",
"(",
"set",
")",
"!=",
"len",
"(",
"sset",
")",
"{",
"return... | // Equals - checks whether given set is equal to current set or not. | [
"Equals",
"-",
"checks",
"whether",
"given",
"set",
"is",
"equal",
"to",
"current",
"set",
"or",
"not",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L88-L103 | train |
minio/minio-go | pkg/set/stringset.go | Intersection | func (set StringSet) Intersection(sset StringSet) StringSet {
nset := NewStringSet()
for k := range set {
if _, ok := sset[k]; ok {
nset.Add(k)
}
}
return nset
} | go | func (set StringSet) Intersection(sset StringSet) StringSet {
nset := NewStringSet()
for k := range set {
if _, ok := sset[k]; ok {
nset.Add(k)
}
}
return nset
} | [
"func",
"(",
"set",
"StringSet",
")",
"Intersection",
"(",
"sset",
"StringSet",
")",
"StringSet",
"{",
"nset",
":=",
"NewStringSet",
"(",
")",
"\n",
"for",
"k",
":=",
"range",
"set",
"{",
"if",
"_",
",",
"ok",
":=",
"sset",
"[",
"k",
"]",
";",
"ok"... | // Intersection - returns the intersection with given set as new set. | [
"Intersection",
"-",
"returns",
"the",
"intersection",
"with",
"given",
"set",
"as",
"new",
"set",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L106-L115 | train |
minio/minio-go | pkg/set/stringset.go | Union | func (set StringSet) Union(sset StringSet) StringSet {
nset := NewStringSet()
for k := range set {
nset.Add(k)
}
for k := range sset {
nset.Add(k)
}
return nset
} | go | func (set StringSet) Union(sset StringSet) StringSet {
nset := NewStringSet()
for k := range set {
nset.Add(k)
}
for k := range sset {
nset.Add(k)
}
return nset
} | [
"func",
"(",
"set",
"StringSet",
")",
"Union",
"(",
"sset",
"StringSet",
")",
"StringSet",
"{",
"nset",
":=",
"NewStringSet",
"(",
")",
"\n",
"for",
"k",
":=",
"range",
"set",
"{",
"nset",
".",
"Add",
"(",
"k",
")",
"\n",
"}",
"\n\n",
"for",
"k",
... | // Union - returns the union with given set as new set. | [
"Union",
"-",
"returns",
"the",
"union",
"with",
"given",
"set",
"as",
"new",
"set",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L130-L141 | train |
minio/minio-go | pkg/set/stringset.go | UnmarshalJSON | func (set *StringSet) UnmarshalJSON(data []byte) error {
sl := []string{}
var err error
if err = json.Unmarshal(data, &sl); err == nil {
*set = make(StringSet)
for _, s := range sl {
set.Add(s)
}
} else {
var s string
if err = json.Unmarshal(data, &s); err == nil {
*set = make(StringSet)
set.Add(s)
}
}
return err
} | go | func (set *StringSet) UnmarshalJSON(data []byte) error {
sl := []string{}
var err error
if err = json.Unmarshal(data, &sl); err == nil {
*set = make(StringSet)
for _, s := range sl {
set.Add(s)
}
} else {
var s string
if err = json.Unmarshal(data, &s); err == nil {
*set = make(StringSet)
set.Add(s)
}
}
return err
} | [
"func",
"(",
"set",
"*",
"StringSet",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"sl",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"var",
"err",
"error",
"\n",
"if",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"data",
",... | // UnmarshalJSON - parses JSON data and creates new set with it.
// If 'data' contains JSON string array, the set contains each string.
// If 'data' contains JSON string, the set contains the string as one element.
// If 'data' contains Other JSON types, JSON parse error is returned. | [
"UnmarshalJSON",
"-",
"parses",
"JSON",
"data",
"and",
"creates",
"new",
"set",
"with",
"it",
".",
"If",
"data",
"contains",
"JSON",
"string",
"array",
"the",
"set",
"contains",
"each",
"string",
".",
"If",
"data",
"contains",
"JSON",
"string",
"the",
"set... | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L152-L169 | train |
minio/minio-go | pkg/set/stringset.go | CreateStringSet | func CreateStringSet(sl ...string) StringSet {
set := make(StringSet)
for _, k := range sl {
set.Add(k)
}
return set
} | go | func CreateStringSet(sl ...string) StringSet {
set := make(StringSet)
for _, k := range sl {
set.Add(k)
}
return set
} | [
"func",
"CreateStringSet",
"(",
"sl",
"...",
"string",
")",
"StringSet",
"{",
"set",
":=",
"make",
"(",
"StringSet",
")",
"\n",
"for",
"_",
",",
"k",
":=",
"range",
"sl",
"{",
"set",
".",
"Add",
"(",
"k",
")",
"\n",
"}",
"\n",
"return",
"set",
"\... | // CreateStringSet - creates new string set with given string values. | [
"CreateStringSet",
"-",
"creates",
"new",
"string",
"set",
"with",
"given",
"string",
"values",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L182-L188 | train |
minio/minio-go | pkg/set/stringset.go | CopyStringSet | func CopyStringSet(set StringSet) StringSet {
nset := NewStringSet()
for k, v := range set {
nset[k] = v
}
return nset
} | go | func CopyStringSet(set StringSet) StringSet {
nset := NewStringSet()
for k, v := range set {
nset[k] = v
}
return nset
} | [
"func",
"CopyStringSet",
"(",
"set",
"StringSet",
")",
"StringSet",
"{",
"nset",
":=",
"NewStringSet",
"(",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"set",
"{",
"nset",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"return",
"nset",
"\n",
"}"
] | // CopyStringSet - returns copy of given set. | [
"CopyStringSet",
"-",
"returns",
"copy",
"of",
"given",
"set",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/pkg/set/stringset.go#L191-L197 | train |
minio/minio-go | api-put-bucket.go | SetBucketPolicy | func (c Client) SetBucketPolicy(bucketName, policy string) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
}
// If policy is empty then delete the bucket policy.
if policy == "" {
return c.removeBucketPolicy(bucketName)
}
// Save the updated policies.
return c.putBucketPolicy(bucketName, policy)
} | go | func (c Client) SetBucketPolicy(bucketName, policy string) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
}
// If policy is empty then delete the bucket policy.
if policy == "" {
return c.removeBucketPolicy(bucketName)
}
// Save the updated policies.
return c.putBucketPolicy(bucketName, policy)
} | [
"func",
"(",
"c",
"Client",
")",
"SetBucketPolicy",
"(",
"bucketName",
",",
"policy",
"string",
")",
"error",
"{",
"// Input validation.",
"if",
"err",
":=",
"s3utils",
".",
"CheckValidBucketName",
"(",
"bucketName",
")",
";",
"err",
"!=",
"nil",
"{",
"retur... | // SetBucketPolicy set the access permissions on an existing bucket. | [
"SetBucketPolicy",
"set",
"the",
"access",
"permissions",
"on",
"an",
"existing",
"bucket",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-bucket.go#L102-L115 | train |
minio/minio-go | api-put-bucket.go | putBucketPolicy | func (c Client) putBucketPolicy(bucketName, policy string) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
}
// Get resources properly escaped and lined up before
// using them in http request.
urlValues := make(url.Values)
urlValues.Set("policy", "")
// Content-length is mandatory for put policy request
policyReader := strings.NewReader(policy)
b, err := ioutil.ReadAll(policyReader)
if err != nil {
return err
}
reqMetadata := requestMetadata{
bucketName: bucketName,
queryValues: urlValues,
contentBody: policyReader,
contentLength: int64(len(b)),
}
// Execute PUT to upload a new bucket policy.
resp, err := c.executeMethod(context.Background(), "PUT", reqMetadata)
defer closeResponse(resp)
if err != nil {
return err
}
if resp != nil {
if resp.StatusCode != http.StatusNoContent {
return httpRespToErrorResponse(resp, bucketName, "")
}
}
return nil
} | go | func (c Client) putBucketPolicy(bucketName, policy string) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
}
// Get resources properly escaped and lined up before
// using them in http request.
urlValues := make(url.Values)
urlValues.Set("policy", "")
// Content-length is mandatory for put policy request
policyReader := strings.NewReader(policy)
b, err := ioutil.ReadAll(policyReader)
if err != nil {
return err
}
reqMetadata := requestMetadata{
bucketName: bucketName,
queryValues: urlValues,
contentBody: policyReader,
contentLength: int64(len(b)),
}
// Execute PUT to upload a new bucket policy.
resp, err := c.executeMethod(context.Background(), "PUT", reqMetadata)
defer closeResponse(resp)
if err != nil {
return err
}
if resp != nil {
if resp.StatusCode != http.StatusNoContent {
return httpRespToErrorResponse(resp, bucketName, "")
}
}
return nil
} | [
"func",
"(",
"c",
"Client",
")",
"putBucketPolicy",
"(",
"bucketName",
",",
"policy",
"string",
")",
"error",
"{",
"// Input validation.",
"if",
"err",
":=",
"s3utils",
".",
"CheckValidBucketName",
"(",
"bucketName",
")",
";",
"err",
"!=",
"nil",
"{",
"retur... | // Saves a new bucket policy. | [
"Saves",
"a",
"new",
"bucket",
"policy",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-bucket.go#L118-L155 | train |
minio/minio-go | api-put-bucket.go | removeBucketPolicy | func (c Client) removeBucketPolicy(bucketName string) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
}
// Get resources properly escaped and lined up before
// using them in http request.
urlValues := make(url.Values)
urlValues.Set("policy", "")
// Execute DELETE on objectName.
resp, err := c.executeMethod(context.Background(), "DELETE", requestMetadata{
bucketName: bucketName,
queryValues: urlValues,
contentSHA256Hex: emptySHA256Hex,
})
defer closeResponse(resp)
if err != nil {
return err
}
return nil
} | go | func (c Client) removeBucketPolicy(bucketName string) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
}
// Get resources properly escaped and lined up before
// using them in http request.
urlValues := make(url.Values)
urlValues.Set("policy", "")
// Execute DELETE on objectName.
resp, err := c.executeMethod(context.Background(), "DELETE", requestMetadata{
bucketName: bucketName,
queryValues: urlValues,
contentSHA256Hex: emptySHA256Hex,
})
defer closeResponse(resp)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"Client",
")",
"removeBucketPolicy",
"(",
"bucketName",
"string",
")",
"error",
"{",
"// Input validation.",
"if",
"err",
":=",
"s3utils",
".",
"CheckValidBucketName",
"(",
"bucketName",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"... | // Removes all policies on a bucket. | [
"Removes",
"all",
"policies",
"on",
"a",
"bucket",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-bucket.go#L158-L179 | train |
minio/minio-go | api-put-bucket.go | SetBucketLifecycle | func (c Client) SetBucketLifecycle(bucketName, lifecycle string) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
}
// If lifecycle is empty then delete it.
if lifecycle == "" {
return c.removeBucketLifecycle(bucketName)
}
// Save the updated lifecycle.
return c.putBucketLifecycle(bucketName, lifecycle)
} | go | func (c Client) SetBucketLifecycle(bucketName, lifecycle string) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
}
// If lifecycle is empty then delete it.
if lifecycle == "" {
return c.removeBucketLifecycle(bucketName)
}
// Save the updated lifecycle.
return c.putBucketLifecycle(bucketName, lifecycle)
} | [
"func",
"(",
"c",
"Client",
")",
"SetBucketLifecycle",
"(",
"bucketName",
",",
"lifecycle",
"string",
")",
"error",
"{",
"// Input validation.",
"if",
"err",
":=",
"s3utils",
".",
"CheckValidBucketName",
"(",
"bucketName",
")",
";",
"err",
"!=",
"nil",
"{",
... | // SetBucketLifecycle set the lifecycle on an existing bucket. | [
"SetBucketLifecycle",
"set",
"the",
"lifecycle",
"on",
"an",
"existing",
"bucket",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-bucket.go#L182-L195 | train |
minio/minio-go | api-put-bucket.go | putBucketLifecycle | func (c Client) putBucketLifecycle(bucketName, lifecycle string) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
}
// Get resources properly escaped and lined up before
// using them in http request.
urlValues := make(url.Values)
urlValues.Set("lifecycle", "")
// Content-length is mandatory for put lifecycle request
lifecycleReader := strings.NewReader(lifecycle)
b, err := ioutil.ReadAll(lifecycleReader)
if err != nil {
return err
}
reqMetadata := requestMetadata{
bucketName: bucketName,
queryValues: urlValues,
contentBody: lifecycleReader,
contentLength: int64(len(b)),
contentMD5Base64: sumMD5Base64(b),
}
// Execute PUT to upload a new bucket lifecycle.
resp, err := c.executeMethod(context.Background(), "PUT", reqMetadata)
defer closeResponse(resp)
if err != nil {
return err
}
if resp != nil {
if resp.StatusCode != http.StatusOK {
return httpRespToErrorResponse(resp, bucketName, "")
}
}
return nil
} | go | func (c Client) putBucketLifecycle(bucketName, lifecycle string) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
}
// Get resources properly escaped and lined up before
// using them in http request.
urlValues := make(url.Values)
urlValues.Set("lifecycle", "")
// Content-length is mandatory for put lifecycle request
lifecycleReader := strings.NewReader(lifecycle)
b, err := ioutil.ReadAll(lifecycleReader)
if err != nil {
return err
}
reqMetadata := requestMetadata{
bucketName: bucketName,
queryValues: urlValues,
contentBody: lifecycleReader,
contentLength: int64(len(b)),
contentMD5Base64: sumMD5Base64(b),
}
// Execute PUT to upload a new bucket lifecycle.
resp, err := c.executeMethod(context.Background(), "PUT", reqMetadata)
defer closeResponse(resp)
if err != nil {
return err
}
if resp != nil {
if resp.StatusCode != http.StatusOK {
return httpRespToErrorResponse(resp, bucketName, "")
}
}
return nil
} | [
"func",
"(",
"c",
"Client",
")",
"putBucketLifecycle",
"(",
"bucketName",
",",
"lifecycle",
"string",
")",
"error",
"{",
"// Input validation.",
"if",
"err",
":=",
"s3utils",
".",
"CheckValidBucketName",
"(",
"bucketName",
")",
";",
"err",
"!=",
"nil",
"{",
... | // Saves a new bucket lifecycle. | [
"Saves",
"a",
"new",
"bucket",
"lifecycle",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-bucket.go#L198-L236 | train |
minio/minio-go | api-put-bucket.go | SetBucketNotification | func (c Client) SetBucketNotification(bucketName string, bucketNotification BucketNotification) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
}
// Get resources properly escaped and lined up before
// using them in http request.
urlValues := make(url.Values)
urlValues.Set("notification", "")
notifBytes, err := xml.Marshal(bucketNotification)
if err != nil {
return err
}
notifBuffer := bytes.NewReader(notifBytes)
reqMetadata := requestMetadata{
bucketName: bucketName,
queryValues: urlValues,
contentBody: notifBuffer,
contentLength: int64(len(notifBytes)),
contentMD5Base64: sumMD5Base64(notifBytes),
contentSHA256Hex: sum256Hex(notifBytes),
}
// Execute PUT to upload a new bucket notification.
resp, err := c.executeMethod(context.Background(), "PUT", reqMetadata)
defer closeResponse(resp)
if err != nil {
return err
}
if resp != nil {
if resp.StatusCode != http.StatusOK {
return httpRespToErrorResponse(resp, bucketName, "")
}
}
return nil
} | go | func (c Client) SetBucketNotification(bucketName string, bucketNotification BucketNotification) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
}
// Get resources properly escaped and lined up before
// using them in http request.
urlValues := make(url.Values)
urlValues.Set("notification", "")
notifBytes, err := xml.Marshal(bucketNotification)
if err != nil {
return err
}
notifBuffer := bytes.NewReader(notifBytes)
reqMetadata := requestMetadata{
bucketName: bucketName,
queryValues: urlValues,
contentBody: notifBuffer,
contentLength: int64(len(notifBytes)),
contentMD5Base64: sumMD5Base64(notifBytes),
contentSHA256Hex: sum256Hex(notifBytes),
}
// Execute PUT to upload a new bucket notification.
resp, err := c.executeMethod(context.Background(), "PUT", reqMetadata)
defer closeResponse(resp)
if err != nil {
return err
}
if resp != nil {
if resp.StatusCode != http.StatusOK {
return httpRespToErrorResponse(resp, bucketName, "")
}
}
return nil
} | [
"func",
"(",
"c",
"Client",
")",
"SetBucketNotification",
"(",
"bucketName",
"string",
",",
"bucketNotification",
"BucketNotification",
")",
"error",
"{",
"// Input validation.",
"if",
"err",
":=",
"s3utils",
".",
"CheckValidBucketName",
"(",
"bucketName",
")",
";",... | // SetBucketNotification saves a new bucket notification. | [
"SetBucketNotification",
"saves",
"a",
"new",
"bucket",
"notification",
"."
] | 68eef499b4c530409962a5d1a12fa8c848587761 | https://github.com/minio/minio-go/blob/68eef499b4c530409962a5d1a12fa8c848587761/api-put-bucket.go#L263-L301 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.