Skip to content

Commit 64ee369

Browse files
authored
Merge pull request #17 from nuclearcat/better-reliability
Handle properly if filename(file0) is missing
2 parents 6316348 + 2de7b6b commit 64ee369

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ curl -X GET https://localhost:3000/v1/checkauth \
8686

8787
The server supports large file uploads up to 4GB and includes upload conflict protection to prevent concurrent uploads to the same file path. Downloads have a 30-second timeout for acquiring file locks.
8888

89+
### Uploading Files with curl
90+
91+
Use `curl`'s multipart form support to send the file contents (`file0`) and target path. The upload endpoint accepts both `/upload` and `/v1/file`.
92+
93+
```bash
94+
curl -X POST http://localhost:3000/v1/file \
95+
-H "Authorization: Bearer <JWT_TOKEN>" \
96+
-F "path=artifacts/build-123" \
97+
-F "file0=@/absolute/path/to/build-output.tar.xz"
98+
```
99+
100+
The resulting object is stored under `artifacts/build-123/<local filename>`. Swap in `/upload` if you prefer the shorter alias or use the public host name instead of `localhost` when interacting with a remote server.
101+
89102
### Metrics
90103

91104
The `/metrics` endpoint provides Prometheus-compatible metrics including:
@@ -96,4 +109,4 @@ Both metrics include hostname, diskname, and mount_point labels.
96109

97110
## API Documentation
98111

99-
See [docs](docs/) for detailed API documentation.
112+
See [docs](docs/) for detailed API documentation.

src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,11 @@ async fn ax_post_file(
497497
file0 = data.to_vec();
498498
match filename {
499499
Some(filename) => file0_filename = filename.to_string(),
500-
None => todo!(),
500+
None => {
501+
let error_msg = "No filename provided".to_string();
502+
eprintln!("{}", error_msg);
503+
return (StatusCode::BAD_REQUEST, error_msg.into_bytes());
504+
}
501505
}
502506
} else {
503507
debug_log!("Unknown field {}: {} bytes", name, data.len());

0 commit comments

Comments
 (0)