Example #1
0
				Body:   file,
			})
			if err != nil {
				return
			}
		}
	}
	return
}

var downloadFileHandler = func(w http.ResponseWriter, req *http.Request) {
	vars := mux.Vars(req)
	bucketName := vars["dir"]
	fileName := vars["file"]
	s3req, _ := s3Client.GetObjectRequest(&s3.GetObjectInput{
		Bucket: aws.String(conf.S3.BucketName),
		Key:    aws.String(bucketName + "/" + fileName),
	})

	presigned, err := s3req.Presign(time.Minute * 10)
	if err != nil {
		http.Error(w, err.Error(), 503)
	}

	http.Redirect(w, req, presigned, 307)
}

var unauthorizedHandler = func(w http.ResponseWriter, req *http.Request) {
	w.Header().Set("Cache-Control", "no-cache")
	w.Header().Set("WWW-Authenticate", fmt.Sprintf(`Basic realm=%q`, "WebRTC Logs"))
	w.WriteHeader(401)
	w.Write([]byte("Unauthorized"))