-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
72 lines (64 loc) · 1.5 KB
/
types.ts
File metadata and controls
72 lines (64 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/** cf worker bindings */
export interface Env {
R2_BUCKET: R2Bucket;
FILE_KV: KVNamespace;
BASE_URL: string;
PRESIGNED_URL_TTL: string;
DEFAULT_FILE_TTL: string;
MAX_FILE_SIZE: string;
CORS_ORIGIN: string;
}
/** metadata */
export interface FileMetadata {
filename: string;
size: number;
mime: string;
uploaded_at: number;
expires_at: number;
downloads_left: number | null; // null = unlimited
password_hash: string | null; // null = no password
r2_key: string;
}
/** /api/v1/upload/init */
export interface UploadInitRequest {
filename: string;
size: number;
mime?: string;
expires_in?: number; // seconds, default from env
max_downloads?: number; // null/0 = unlimited
password?: string; // optional password protection
}
/** /api/v1/upload/init */
export interface UploadInitResponse {
upload_url: string;
file_uuid: string;
expires_at: number;
}
/** /api/v1/upload/finalize */
export interface UploadFinalizeRequest {
file_uuid: string;
}
/** /api/v1/upload/finalize */
export interface UploadFinalizeResponse {
download_link: string;
status: "active";
}
/** /api/v1/file/:uuid/info */
export interface FileInfoResponse {
filename: string;
size: number;
mime: string;
uploaded_at: number;
expires_at: number;
downloads_left: number | null;
has_password: boolean;
}
/** /api/v1/file/:uuid/download */
export interface DownloadQuery {
password?: string;
}
/** generic error response */
export interface ErrorResponse {
error: string;
code: string;
}