- `use crate::` where appropriate - cleanup CLI parsing - `Uri::with_protocol` -> `Uri::new`
62 lines
2 KiB
Markdown
62 lines
2 KiB
Markdown
# Outline of sharry upload API
|
|
|
|
1. POST to "new" route
|
|
- uri: https://sharry.yavook.de/api/v2/alias/upload/new
|
|
- hdr: `Sharry-Alias: $alias_id`
|
|
- res.status == 200
|
|
- res_json.success == true
|
|
- res_json.message == "Share created."
|
|
- $share_id := res_json.id
|
|
|
|
1. POST to "tus" route
|
|
- uri: https://sharry.yavook.de/api/v2/alias/upload/$share_id/files/tus
|
|
- hdr: `Sharry-Alias: $alias_id`
|
|
- hdr: `Sharry-File-Length: $file_bytes`
|
|
- hdr: `Sharry-File-Name: $file_name`
|
|
- hdr: `Sharry-File-Type: $file_mimetype`
|
|
- hdr: `Tus-Resumable: 1.0.0`
|
|
- hdr: `Upload-Length: $file_bytes`
|
|
- res.status == 201
|
|
- $patch_uri := res_hdr.Location
|
|
|
|
1. (multi) PATCH to "$patch_uri"
|
|
- hdr: `Sharry-Alias`, `Sharry-File-Length`, `Sharry-File-Name`, `Sharry-File-Type`, `Tus-Resumable`
|
|
- hdr: `Upload-Offset: 10485760 * (n-1)` for nth chunk
|
|
- body: up to 10 MiB of binary data
|
|
- res.status == 204
|
|
- better use res_hdr.Upload-Offset
|
|
|
|
1. (opt) POST to "notify" route
|
|
- uri: https://sharry.yavook.de/api/v2/alias/mail/notify/$share_id
|
|
- hdr: `Sharry-Alias`
|
|
- res.status == 200
|
|
- res_json.success, res_json.message
|
|
|
|
|
|
# Links
|
|
|
|
- yvk repo: https://code.yavook.de/jmm/shrupl
|
|
- sharry issue: https://github.com/eikek/sharry/issues/1659
|
|
- ureq: https://stackoverflow.com/questions/59586787/rust-how-to-do-http-put-of-large-files
|
|
- hashing: https://duckduckgo.com/?q=rust+get+file+hash&t=canonical&ia=web
|
|
- https://stackoverflow.com/q/69787906
|
|
- https://github.com/RustCrypto/hashes
|
|
|
|
|
|
# Ideas
|
|
|
|
- cli functions
|
|
- max retries => stop
|
|
- "continue" and "new" flags to avoid user interaction
|
|
- "quiet" flag to disable output entirely
|
|
- "verbose" flag to adjust RUST_LOG for `shrupl` crate
|
|
- some switch to change log to "pretty-print"
|
|
|
|
- client error rework
|
|
- current variants are too "low level"
|
|
- use variants like `InvalidEndpoint`, `InvalidAlias` etc.
|
|
- `Uploading::abort() -> Checked`
|
|
|
|
- hashing
|
|
- store file hashes with all `file::*` variants
|
|
- check hashes on "continue"
|