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

Accept files in PWA Web Share Target #8880

Open
tamaina opened this issue Jun 23, 2022 · 8 comments
Open

Accept files in PWA Web Share Target #8880

tamaina opened this issue Jun 23, 2022 · 8 comments
Labels
✨Feature This adds/improves/enhances a feature packages/sw and PWA ServiceWorker and PWA related issue/PR

Comments

@tamaina
Copy link
Contributor

tamaina commented Jun 23, 2022

PWAのshare_targetでファイルを受け付けるようにする

Summary

PWAのshare_targetでファイルを受け付けるようにし、画像などの共有ができるようにしたい。

https://w3c.github.io/web-share-target/level-2/
https://web.dev/web-share-target/#accepting-files

実装イメージ

manifest.json

{
	"share_target": {
		"action": "/sw/share",
		"method": "POST",
		"enctype": "multipart/form-data",
		"params": {
			"title": "title",
			"text": "text",
			"url": "url",
			"files": [
				{
					"name": "file",
					"accept": "*/*"
				}
			]
		}
	}
}

sw.ts

onfetchで/sw/shareをPOSTかつmultipart/form-dataで叩かれた場合は良い感じにクエリ生成やファイルアップロードするなどしてself.clients.openWindow(/share?${ii_kanjino_query})

https://web.dev/web-share-target/#processing-post-shares

@tamaina tamaina added the ✨Feature This adds/improves/enhances a feature label Jun 23, 2022
@tamaina tamaina changed the title PWAのshare_targetでファイルを受け付けるようにする Accept files in PWA's share_target Jun 23, 2022
@tamaina tamaina changed the title Accept files in PWA's share_target Accept files in PWA Web Share Target Jun 23, 2022
@tamaina
Copy link
Contributor Author

tamaina commented Dec 5, 2022

アップロード中は通知でアップロードの状態を表示する必要があるかも

@tamaina tamaina added the packages/sw and PWA ServiceWorker and PWA related issue/PR label Dec 17, 2022
@tamaina
Copy link
Contributor Author

tamaina commented Dec 17, 2022

sw.tsでファイルをアップロードする必要があるんだけど、browser-image-resizerはOffscreenCanvasないと多分無理なので画像圧縮は無理か

@rinsuki
Copy link
Contributor

rinsuki commented Dec 17, 2022

Web Share Target あるなら OffscreenCanvas もあるのでは、というか一回idbあたりにしまっておけばいいのでは

@tamaina
Copy link
Contributor Author

tamaina commented Dec 18, 2022

たしかに

@tamaina
Copy link
Contributor Author

tamaina commented Apr 7, 2023

iOS 16.4からOffscreenCanvas対応した

@syuilo
Copy link
Member

syuilo commented Apr 7, 2023

うおおおおおおお

@tamaina
Copy link
Contributor Author

tamaina commented Apr 30, 2023

深夜テンションでbrowser-image-resizerをOffscreenCanvasにした

https://github.com/misskey-dev/browser-image-resizer/releases/tag/v2.2.1-misskey.4

@bil-ash
Copy link

bil-ash commented Jan 14, 2025

@tamaina Any updates on this feature? It would be very nice to have this feature along with the ability to not only upload images but also audio and video files via web-share-target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨Feature This adds/improves/enhances a feature packages/sw and PWA ServiceWorker and PWA related issue/PR
Projects
Development

No branches or pull requests

4 participants