"fmt"
"hash"
"io"
+ "mime"
"net/http"
"net/textproto"
"net/url"
}
func setFileInfoHeaders(header http.Header, fs arvados.CustomFileSystem, path string) error {
+ maybeEncode := func(s string) string {
+ for _, c := range s {
+ if c > '\u007f' {
+ return mime.BEncoding.Encode("UTF-8", s)
+ }
+ }
+ return s
+ }
path = strings.TrimSuffix(path, "/")
var props map[string]interface{}
for {
}
k = "x-amz-meta-" + k
if s, ok := v.(string); ok {
- header.Set(k, s)
+ header.Set(k, maybeEncode(s))
} else if j, err := json.Marshal(v); err == nil {
- header.Set(k, string(j))
+ header.Set(k, maybeEncode(string(j)))
}
}
return nil
"crypto/sha256"
"fmt"
"io/ioutil"
+ "mime"
"net/http"
"net/http/httptest"
"net/url"
"name": "keep-web s3 test collection",
"manifest_text": ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:emptyfile\n./emptydir d41d8cd98f00b204e9800998ecf8427e+0 0:0:.\n",
"properties": map[string]interface{}{
- "string": "string value",
- "array": []string{"element1", "element2"},
- "object": map[string]interface{}{"key": map[string]interface{}{"key2": "value"}},
+ "string": "string value",
+ "array": []string{"element1", "element2"},
+ "object": map[string]interface{}{"key": map[string]interface{}{"key2": "value⛵"}},
+ "nonascii": "⛵",
},
}})
c.Assert(err, check.IsNil)
defer stage.teardown(c)
expectCollectionTags := map[string]string{
- "String": "string value",
- "Array": `["element1","element2"]`,
- "Object": `{"key":{"key2":"value"}}`,
+ "String": "string value",
+ "Array": `["element1","element2"]`,
+ "Object": mime.BEncoding.Encode("UTF-8", `{"key":{"key2":"value⛵"}}`),
+ "Nonascii": "=?UTF-8?b?4pu1?=",
}
expectSubprojectTags := map[string]string{
"Subproject_properties_key": "subproject properties value",