func uploadFileInfo(fi *FileInfo) { timeStart := time.Now() pathRemote := fi.S3FullPath pathLocal := fi.Path fmt.Printf("uploadFileInfo(): %s => %s, pub: %v, %d bytes", pathLocal, pathRemote, isPublic(), fi.Size) if sha1ExistsInS3Must(fi.Sha1Hex) { // TODO: if different permissions (public vs. private), change the perms // TODO: for extra paranoia could verify that fi.Size matches size in S3 fmt.Printf(" skipping because already exists\n") return } bucket := s3GetBucket() d, err := ioutil.ReadFile(pathLocal) fataliferr(err) mimeType := mime.TypeByExtension(filepath.Ext(pathLocal)) perm := s3.Private if isPublic() { perm = s3.PublicRead } opts := s3.Options{} opts.Meta = make(map[string][]string) opts.Meta["name"] = []string{filepath.Base(pathLocal)} opts.ContentMD5 = fi.Md5B64 err = bucket.Put(pathRemote, d, mimeType, perm, opts) fataliferr(err) fmt.Printf(" took %s\n", time.Since(timeStart)) }