aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/swarm/upload.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/swarm/upload.go')
-rw-r--r--cmd/swarm/upload.go26
1 files changed, 4 insertions, 22 deletions
diff --git a/cmd/swarm/upload.go b/cmd/swarm/upload.go
index f76cb1b98..2225127cf 100644
--- a/cmd/swarm/upload.go
+++ b/cmd/swarm/upload.go
@@ -22,16 +22,15 @@ import (
"fmt"
"io"
"io/ioutil"
- "mime"
- "net/http"
"os"
"os/user"
"path"
"path/filepath"
"strings"
- "github.com/ethereum/go-ethereum/cmd/utils"
swarm "github.com/ethereum/go-ethereum/swarm/api/client"
+
+ "github.com/ethereum/go-ethereum/cmd/utils"
"gopkg.in/urfave/cli.v1"
)
@@ -118,10 +117,9 @@ func upload(ctx *cli.Context) {
return "", fmt.Errorf("error opening file: %s", err)
}
defer f.Close()
- if mimeType == "" {
- mimeType = detectMimeType(file)
+ if mimeType != "" {
+ f.ContentType = mimeType
}
- f.ContentType = mimeType
return client.Upload(f, "", toEncrypt)
}
}
@@ -161,19 +159,3 @@ func homeDir() string {
}
return ""
}
-
-func detectMimeType(file string) string {
- if ext := filepath.Ext(file); ext != "" {
- return mime.TypeByExtension(ext)
- }
- f, err := os.Open(file)
- if err != nil {
- return ""
- }
- defer f.Close()
- buf := make([]byte, 512)
- if n, _ := f.Read(buf); n > 0 {
- return http.DetectContentType(buf)
- }
- return ""
-}