mirror of
https://github.com/rclone/rclone.git
synced 2024-11-30 04:23:48 +08:00
google cloud storage: set the Content-Type from the file name
This commit is contained in:
parent
b72fc69fbe
commit
c91c96565f
|
@ -14,6 +14,7 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -475,14 +476,17 @@ func (o *FsObjectStorage) Open() (in io.ReadCloser, err error) {
|
||||||
//
|
//
|
||||||
// The new object may have been created if an error is returned
|
// The new object may have been created if an error is returned
|
||||||
func (o *FsObjectStorage) Update(in io.Reader, modTime time.Time, size int64) error {
|
func (o *FsObjectStorage) Update(in io.Reader, modTime time.Time, size int64) error {
|
||||||
// FIXME Set the mtime
|
// Guess the content type
|
||||||
|
contentType := mime.TypeByExtension(path.Ext(o.remote))
|
||||||
|
if contentType == "" {
|
||||||
|
contentType = "application/octet-stream"
|
||||||
|
}
|
||||||
|
|
||||||
object := storage.Object{
|
object := storage.Object{
|
||||||
// FIXME other stuff here? ACL??
|
// FIXME other stuff here? ACL??
|
||||||
Bucket: o.storage.bucket,
|
Bucket: o.storage.bucket,
|
||||||
Name: o.storage.root + o.remote,
|
Name: o.storage.root + o.remote,
|
||||||
// ContentType: ???
|
ContentType: contentType,
|
||||||
// Crc32c: ??? // set this - will it get checked?
|
|
||||||
// Md5Hash: will this get checked?
|
|
||||||
Size: uint64(size),
|
Size: uint64(size),
|
||||||
Updated: modTime.Format(RFC3339Out), // Doesn't get set
|
Updated: modTime.Format(RFC3339Out), // Doesn't get set
|
||||||
Metadata: metadataFromModTime(modTime),
|
Metadata: metadataFromModTime(modTime),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user