Encode input URL path to URL encoded path.
(req *http.Request, virtualHost bool)
| 40 | |
| 41 | // Encode input URL path to URL encoded path. |
| 42 | func encodeURL2Path(req *http.Request, virtualHost bool) (path string) { |
| 43 | if virtualHost { |
| 44 | reqHost := getHostAddr(req) |
| 45 | dotPos := strings.Index(reqHost, ".") |
| 46 | if dotPos > -1 { |
| 47 | bucketName := reqHost[:dotPos] |
| 48 | path = "/" + bucketName |
| 49 | path += req.URL.Path |
| 50 | path = s3utils.EncodePath(path) |
| 51 | return path |
| 52 | } |
| 53 | } |
| 54 | path = s3utils.EncodePath(req.URL.Path) |
| 55 | return path |
| 56 | } |
| 57 | |
| 58 | // PreSignV2 - presign the request in following style. |
| 59 | // https://${S3_BUCKET}.s3.amazonaws.com/${S3_OBJECT}?AWSAccessKeyId=${S3_ACCESS_KEY}&Expires=${TIMESTAMP}&Signature=${SIGNATURE}. |