Skip to content

Commit e6f1413

Browse files
authored
Make resumable uploads work from browser with signed url (#1022)
* Expose location header for cors requests * Add missing Access-Control-Allow-Origin header for get request * Add Content-Range to allowed headers
1 parent 041da75 commit e6f1413

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

fakestorage/object.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ func (s *Server) downloadObject(w http.ResponseWriter, r *http.Request) {
813813
for name, value := range obj.Metadata {
814814
w.Header().Set("X-Goog-Meta-"+name, value)
815815
}
816+
w.Header().Set("Access-Control-Allow-Origin", "*")
816817

817818
if ranged && !satisfiable {
818819
status = http.StatusRequestedRangeNotSatisfiable

fakestorage/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func NewServerWithOptions(options Options) (*Server, error) {
125125
return nil, err
126126
}
127127

128-
allowedHeaders := []string{"Content-Type", "Content-Encoding", "Range"}
128+
allowedHeaders := []string{"Content-Type", "Content-Encoding", "Range", "Content-Range"}
129129
allowedHeaders = append(allowedHeaders, options.AllowedCORSHeaders...)
130130

131131
cors := handlers.CORS(
@@ -140,6 +140,7 @@ func NewServerWithOptions(options Options) (*Server, error) {
140140
handlers.AllowedHeaders(allowedHeaders),
141141
handlers.AllowedOrigins([]string{"*"}),
142142
handlers.AllowCredentials(),
143+
handlers.ExposedHeaders([]string{"Location"}),
143144
)
144145

145146
handler := cors(s.mux)

0 commit comments

Comments
 (0)