MCPcopy Create free account
hub / github.com/rclone/rclone / setMetaData

Method setMetaData

backend/oracleobjectstorage/object.go:129–173  ·  view source on GitHub ↗
(
	contentLength *int64,
	contentMd5 *string,
	contentType *string,
	lastModified *common.SDKTime,
	storageTier any,
	meta map[string]string)

Source from the content-addressed store, hash-verified

127}
128
129func (o *Object) setMetaData(
130 contentLength *int64,
131 contentMd5 *string,
132 contentType *string,
133 lastModified *common.SDKTime,
134 storageTier any,
135 meta map[string]string) error {
136
137 if contentLength != nil {
138 o.bytes = *contentLength
139 }
140 if contentMd5 != nil {
141 md5, err := o.base64ToMd5(*contentMd5)
142 if err == nil {
143 o.md5 = md5
144 }
145 }
146 o.meta = meta
147 if o.meta == nil {
148 o.meta = map[string]string{}
149 }
150 // Read MD5 from metadata if present
151 if md5sumBase64, ok := o.meta[metaMD5Hash]; ok {
152 md5, err := o.base64ToMd5(md5sumBase64)
153 if err != nil {
154 o.md5 = md5
155 }
156 }
157 if lastModified == nil {
158 o.lastModified = time.Now()
159 fs.Logf(o, "Failed to read last modified")
160 } else {
161 o.lastModified = lastModified.Time
162 }
163 if contentType != nil {
164 o.mimeType = *contentType
165 }
166 if storageTier == nil || storageTier == "" {
167 o.storageTier = storageTierMap[standard]
168 } else {
169 tier := strings.ToLower(fmt.Sprintf("%v", storageTier))
170 o.storageTier = storageTierMap[tier]
171 }
172 return nil
173}
174
175func (o *Object) base64ToMd5(md5sumBase64 string) (md5 string, err error) {
176 md5sumBytes, err := base64.StdEncoding.DecodeString(md5sumBase64)

Callers 2

decodeMetaDataHeadMethod · 0.95
decodeMetaDataObjectMethod · 0.95

Calls 2

base64ToMd5Method · 0.95
LogfFunction · 0.92

Tested by

no test coverage detected