File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 7
7
package lib
8
8
9
9
import (
10
+ "bufio"
10
11
"bytes"
11
12
"compress/gzip"
12
13
"crypto/md5"
@@ -16,7 +17,7 @@ import (
16
17
"io"
17
18
"io/ioutil"
18
19
"log"
19
- "mime "
20
+ "net/http "
20
21
"os"
21
22
"path"
22
23
"path/filepath"
@@ -412,11 +413,15 @@ func (d *Deployer) upload(source file, destBucket *s3.Bucket) error {
412
413
}
413
414
defer f .Close ()
414
415
415
- contentType := mime .TypeByExtension (filepath .Ext (source .path ))
416
- if contentType == "" {
417
- contentType = "application/octet-stream"
416
+ br := bufio .NewReader (f )
417
+ const magicSize = 512 // Size that DetectContentType expects
418
+ peek , err := br .Peek (magicSize )
419
+ if err != nil {
420
+ return err
418
421
}
419
422
423
+ contentType := http .DetectContentType (peek )
424
+
420
425
headers := map [string ][]string {
421
426
"Content-Type" : {contentType },
422
427
}
@@ -428,7 +433,7 @@ func (d *Deployer) upload(source file, destBucket *s3.Bucket) error {
428
433
}
429
434
430
435
var (
431
- r io.Reader = f
436
+ r io.Reader = br
432
437
size = source .size
433
438
)
434
439
You can’t perform that action at this time.
0 commit comments