mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
Merge remote-tracking branch 'origin/bzz' into bzz
Conflicts: bzz/api.go
This commit is contained in:
commit
6b9ea28eea
1 changed files with 13 additions and 10 deletions
23
bzz/api.go
23
bzz/api.go
|
|
@ -2,12 +2,12 @@ package bzz
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
// "net"
|
||||||
|
// "net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -320,16 +320,19 @@ func (self *Api) Upload(lpath, index string) (string, error) {
|
||||||
list[i].Hash = fmt.Sprintf("%064x", hash)
|
list[i].Hash = fmt.Sprintf("%064x", hash)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
cmd := exec.Command("file", "--mime-type", "-b", entry.Path)
|
first512 := make([]byte, 512)
|
||||||
// cmd := exec.Command("mimetype", "-b", entry.Path)
|
fread, _ := sr.ReadAt(first512, 0)
|
||||||
var out bytes.Buffer
|
if fread > 0 {
|
||||||
cmd.Stdout = &out
|
mimeType := http.DetectContentType(first512[:fread])
|
||||||
err = cmd.Run()
|
if filepath.Ext(entry.Path) == ".css" {
|
||||||
if err == nil {
|
mimeType = "text/css"
|
||||||
list[i].ContentType = strings.TrimSuffix(out.String(), "\n")
|
|
||||||
}
|
}
|
||||||
|
list[i].ContentType = mimeType
|
||||||
|
//fmt.Printf("%v %v %v\n", entry.Path, mimeType, filepath.Ext(entry.Path))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f.Close()
|
||||||
}
|
}
|
||||||
errors[i] = err
|
errors[i] = err
|
||||||
done <- true
|
done <- true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue