Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mime type change #111

Merged
merged 6 commits into from
Jun 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions rs/rs_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ func (rs Client) Copy(l rpc.Logger, bucketSrc, keySrc, bucketDest, keyDest strin
return rs.Conn.Call(l, nil, RS_HOST+URICopy(bucketSrc, keySrc, bucketDest, keyDest))
}

// ----------------------------------------------------------
func (rs Client) ChangeMime(l rpc.Logger, bucket, key, mime string) (err error) {
return rs.Conn.Call(l, nil, RS_HOST+URIChangeMime(bucket, key, mime))
}

func encodeURI(uri string) string {
return base64.URLEncoding.EncodeToString([]byte(uri))
Expand All @@ -78,4 +80,6 @@ func URIMove(bucketSrc, keySrc, bucketDest, keyDest string) string {
return "/move/" + encodeURI(bucketSrc+":"+keySrc) + "/" + encodeURI(bucketDest+":"+keyDest)
}

// ----------------------------------------------------------
func URIChangeMime(bucket, key, mime string) string {
return "/chgm/" + encodeURI(bucket+":"+key) + "/mime/" + encodeURI(mime)
}
14 changes: 14 additions & 0 deletions rs/rs_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ func TestEntry(t *testing.T) {
t.Fatal(err)
}

mime := "text/plain"
err = client.ChangeMime(nil, bucketName, key, mime)
if err != nil {
t.Fatal(err)
}

einfo, err = client.Stat(nil, bucketName, key)
if err != nil {
t.Fatal(err)
}
if einfo.MimeType != mime {
t.Fatal("mime type did not change")
}

err = client.Copy(nil, bucketName, key, bucketName, newkey1)
if err != nil {
t.Fatal(err)
Expand Down