-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make gateway POST handle multipart file & pin flag #2205
Conversation
a471686
to
666b755
Compare
Test fixed. rht@666b755#diff-cbe32203deec9b995950e3110e5db668R69 is an example of adding an array of files (could be in the form of Several apis to look at, in the order of decreasing features:
None of them support upload of multiple files in a single POST request. imo, further dedup with |
354b964
to
7c413fb
Compare
@@ -55,6 +55,22 @@ func NewFileFromPart(part *multipart.Part) (File, error) { | |||
return f, nil | |||
} | |||
|
|||
func NewFileFromRequest(r *http.Request) (File, error) { | |||
contentType := r.Header.Get(contentTypeHeader) | |||
mediaType, _, _ := mime.ParseMediaType(contentType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err ignored due to ce49541. If there is a more semantic way to express that this is run only when files are involved, including the statement used to state this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redirect: #2226
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont understand this statement.
odd, travis didn't run... @rht can you rebase + push again so travis runs? thanks |
return "", err | ||
} | ||
|
||
dopin := r.FormValue("pin") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldnt use the form value, this check should check the command option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah nvm there is no command, it's gateway
License: MIT Signed-off-by: rht <rhtbot@gmail.com>
7c413fb
to
d6d0a2b
Compare
Rebased. |
so, just to make sure i understand the goal here. You're wanting to use the unixfs fileAdder for writeable gateway code? |
Yes, this dedup has been intended since #1543. |
@@ -301,21 +303,57 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request | |||
} | |||
|
|||
func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { | |||
nd, err := i.newDagFromReader(r.Body) | |||
fileAdder, err := coreunix.NewAdder(i.node.Context(), i.node, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should use the closenotify code like in the get or head requests to make sure we don't have lingering uncanceled contexts from here.
just one context thing and then LGTM. |
License: MIT Signed-off-by: rht <rhtbot@gmail.com>
Added the context closenotifer to all gateway requests. |
An updated #1845