Skip to content
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

Give example with POST and state POST semantics #57

Open
mgiuca opened this issue Jul 26, 2018 · 4 comments · Fixed by #58
Open

Give example with POST and state POST semantics #57

mgiuca opened this issue Jul 26, 2018 · 4 comments · Fixed by #58
Assignees

Comments

@mgiuca
Copy link
Collaborator

mgiuca commented Jul 26, 2018

Raised in w3ctag/design-reviews#221.

@slightlyoff: "It would be great to see expanded examples, particularly ones that demonstrate how to deal with files and the POST mechanism from Service Workers. These don't seem to be in either the spec or explainer yet."

We shouldn't have files (since we don't support that yet), but we should give an example of receiving a POST, and non-normatively state the semantics we expect (the usual; that if you're going to perform a side-effect from the HTTP request without any prior user interaction, it should be a POST).

ewilligers pushed a commit to ewilligers/web-share-target that referenced this issue Jul 31, 2018
We now have an example of receiving a POST, and state POST semantics.

resolves w3c#57
ewilligers pushed a commit to ewilligers/web-share-target that referenced this issue Aug 6, 2018
We now have an example of receiving a POST, and state POST semantics.

resolves w3c#57
ewilligers added a commit that referenced this issue Aug 6, 2018
* Example with POST

We now have an example of receiving a POST, and state POST semantics.

resolves #57
@mgiuca
Copy link
Collaborator Author

mgiuca commented Jul 12, 2019

This issue has come up in the design of ST, about how to deal with a POST share target and send the data to the newly opened page without roundtripping via the server. It can be done but it's non-trivial and hard to figure out (see Squoosh which handles share targets by a complex dance of waiting for the client to open, then postMessaging to the new client).

The current POST example doesn't really go into that; it just forwards the request to the server. I'd like to make an example (or possibly even a library) that makes it easier to do the above dance.

@mgiuca mgiuca reopened this Jul 12, 2019
@mgiuca mgiuca self-assigned this Jul 12, 2019
@mgiuca
Copy link
Collaborator Author

mgiuca commented Jul 12, 2019

@raymeskhoury

@incognico
Copy link

Maybe this is a bit off-topic but consider my use case:

I have a simple PWA which basically is a upload form with an input type file for an image and a description input type text. The idea was to use the share target to directly share an image, preview it in the PWA, let the user add a description and submit the form.

It is all well working until the actual upload part as you can't just add a File object to an input[type=file] for security reasons (the user must intentionally fill it by himself). It is only possible to assign a FileList object. This currently is only returned by DataTransfer which is part of the HTML5 Drag and Drop API. Working around this by creating a bloburl and let the user drop the preview into the input[type=file] to "consent" does not work on mobile because there are no drag, only touch events.

The current workaround is just to replicate the form in the service worker and use xhr to basically POST the exactly same thing I would have either way. Feels kind of stupid to me as the user has already "consent" to use the shared image by manually selecting it and hitting the share intent, this part feels missing to me.

Probably an edge case but there are my 2c.

@mgiuca
Copy link
Collaborator Author

mgiuca commented Apr 22, 2020

That is a very interesting edge case. Probably just something we haven't thought of: essentially you want to receive a share but not post it to the server right away, but load it up into a web form that can be posted using conventional form posting?

I'd say your workaround is correct (use XHR to post it is the only way to go, if you are intercepting the initial share POST using a service worker).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants