upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/96.md
diff options
context:
space:
mode:
authorFrancisco Calderón <fjcalderon@gmail.com>2024-11-04 15:39:21 -0300
committerGitHub <noreply@github.com>2024-11-04 15:39:21 -0300
commit03f3bc39678262ecbd5d870c9da44723023557ff (patch)
treee75ecf32d3bc906a8b26314488a1ae90996169c1 /96.md
parentf72a2f69ed93cf442e83bf9e7e16f6c06da40384 (diff)
parent6bcd89c097e97e65dbc95e7c6b7b8348e8dd6b5c (diff)
Merge branch 'master' into p2p-nip
Diffstat (limited to '96.md')
-rw-r--r--96.md61
1 files changed, 31 insertions, 30 deletions
diff --git a/96.md b/96.md
index 2f25351..05c1b18 100644
--- a/96.md
+++ b/96.md
@@ -1,6 +1,8 @@
1# NIP-96 1NIP-96
2======
2 3
3## HTTP File Storage Integration 4HTTP File Storage Integration
5-----------------------------
4 6
5`draft` `optional` 7`draft` `optional`
6 8
@@ -17,7 +19,7 @@ will not have to learn anything about nostr relays.
17 19
18File storage servers wishing to be accessible by nostr users should opt-in by making available an https route at `/.well-known/nostr/nip96.json` with `api_url`: 20File storage servers wishing to be accessible by nostr users should opt-in by making available an https route at `/.well-known/nostr/nip96.json` with `api_url`:
19 21
20```js 22```jsonc
21{ 23{
22 // Required 24 // Required
23 // File upload and deletion are served from this url 25 // File upload and deletion are served from this url
@@ -57,7 +59,7 @@ File storage servers wishing to be accessible by nostr users should opt-in by ma
57 "file_expiration": [14, 90], 59 "file_expiration": [14, 90],
58 "media_transformations": { 60 "media_transformations": {
59 "image": [ 61 "image": [
60 'resizing' 62 "resizing"
61 ] 63 ]
62 } 64 }
63 } 65 }
@@ -125,14 +127,14 @@ The `server` MUST link the user's `pubkey` string as the owner of the file so to
125 127
126The upload response is a json object as follows: 128The upload response is a json object as follows:
127 129
128```js 130```jsonc
129{ 131{
130 // "success" if successful or "error" if not 132 // "success" if successful or "error" if not
131 status: "success", 133 "status": "success",
132 // Free text success, failure or info message 134 // Free text success, failure or info message
133 message: "Upload successful.", 135 "message": "Upload successful.",
134 // Optional. See "Delayed Processing" section 136 // Optional. See "Delayed Processing" section
135 processing_url: "...", 137 "processing_url": "...",
136 // This uses the NIP-94 event format but DO NOT need 138 // This uses the NIP-94 event format but DO NOT need
137 // to fill some fields like "id", "pubkey", "created_at" and "sig" 139 // to fill some fields like "id", "pubkey", "created_at" and "sig"
138 // 140 //
@@ -141,9 +143,9 @@ The upload response is a json object as follows:
141 // and, optionally, all file metadata the server wants to make available 143 // and, optionally, all file metadata the server wants to make available
142 // 144 //
143 // nip94_event field is absent if unsuccessful upload 145 // nip94_event field is absent if unsuccessful upload
144 nip94_event: { 146 "nip94_event": {
145 // Required tags: "url" and "ox" 147 // Required tags: "url" and "ox"
146 tags: [ 148 "tags": [
147 // Can be same from /.well-known/nostr/nip96.json's "download_url" field 149 // Can be same from /.well-known/nostr/nip96.json's "download_url" field
148 // (or "api_url" field if "download_url" is absent or empty) with appended 150 // (or "api_url" field if "download_url" is absent or empty) with appended
149 // original file hash. 151 // original file hash.
@@ -164,12 +166,12 @@ The upload response is a json object as follows:
164 // The server can but does not need to store this value. 166 // The server can but does not need to store this value.
165 ["x", "543244319525d9d08dd69cb716a18158a249b7b3b3ec4bbde5435543acb34443"], 167 ["x", "543244319525d9d08dd69cb716a18158a249b7b3b3ec4bbde5435543acb34443"],
166 // Optional. Recommended for helping clients to easily know file type before downloading it. 168 // Optional. Recommended for helping clients to easily know file type before downloading it.
167 ["m", "image/png"] 169 ["m", "image/png"],
168 // Optional. Recommended for helping clients to reserve an adequate UI space to show the file before downloading it. 170 // Optional. Recommended for helping clients to reserve an adequate UI space to show the file before downloading it.
169 ["dim", "800x600"] 171 ["dim", "800x600"]
170 // ... other optional NIP-94 tags 172 // ... other optional NIP-94 tags
171 ], 173 ],
172 content: "" 174 "content": ""
173 }, 175 },
174 // ... other custom fields (please consider adding them to this NIP or to NIP-94 tags) 176 // ... other custom fields (please consider adding them to this NIP or to NIP-94 tags)
175} 177}
@@ -200,12 +202,12 @@ the file processing is done.
200 202
201If the processing isn't done, the server should reply at the `processing_url` url with **200 OK** and the following JSON: 203If the processing isn't done, the server should reply at the `processing_url` url with **200 OK** and the following JSON:
202 204
203``` 205```jsonc
204{ 206{
205 // It should be "processing". If "error" it would mean the processing failed. 207 // It should be "processing". If "error" it would mean the processing failed.
206 status: "processing", 208 "status": "processing",
207 message: "Processing. Please check again later for updated status.", 209 "message": "Processing. Please check again later for updated status.",
208 percentage: 15 // Processing percentage. An integer between 0 and 100. 210 "percentage": 15 // Processing percentage. An integer between 0 and 100.
209} 211}
210``` 212```
211 213
@@ -268,10 +270,10 @@ in the same file hash).
268 270
269The successful response is a 200 OK one with just basic JSON fields: 271The successful response is a 200 OK one with just basic JSON fields:
270 272
271``` 273```json
272{ 274{
273 status: "success", 275 "status": "success",
274 message: "File deleted." 276 "message": "File deleted."
275} 277}
276``` 278```
277 279
@@ -285,7 +287,7 @@ Returns a list of files linked to the authenticated users pubkey.
285 287
286Example Response: 288Example Response:
287 289
288```js 290```jsonc
289{ 291{
290 "count": 1, // server page size, eg. max(1, min(server_max_page_size, arg_count)) 292 "count": 1, // server page size, eg. max(1, min(server_max_page_size, arg_count))
291 "total": 1, // total number of files 293 "total": 1, // total number of files
@@ -293,17 +295,16 @@ Example Response:
293 "files": [ 295 "files": [
294 { 296 {
295 "tags": [ 297 "tags": [
296 ["ox": "719171db19525d9d08dd69cb716a18158a249b7b3b3ec4bbdec5698dca104b7b"], 298 ["ox", "719171db19525d9d08dd69cb716a18158a249b7b3b3ec4bbdec5698dca104b7b"],
297 ["x": "5d2899290e0e69bcd809949ee516a4a1597205390878f780c098707a7f18e3df"], 299 ["x", "5d2899290e0e69bcd809949ee516a4a1597205390878f780c098707a7f18e3df"],
298 ["size", "123456"], 300 ["size", "123456"],
299 ["alt", "a meme that makes you laugh"], 301 ["alt", "a meme that makes you laugh"],
300 ["expiration", "1715691139"], 302 ["expiration", "1715691139"],
301 // ...other metadata 303 // ...other metadata
302 ] 304 ],
303 "content": "haha funny meme", // caption 305 "content": "haha funny meme", // caption
304 "created_at": 1715691130 // upload timestmap 306 "created_at": 1715691130 // upload timestamp
305 }, 307 }
306 ...
307 ] 308 ]
308} 309}
309``` 310```
@@ -322,14 +323,14 @@ Note: HTTP File Storage Server developers may skip this section. This is meant f
322A File Server Preference event is a kind 10096 replaceable event meant to select one or more servers the user wants 323A File Server Preference event is a kind 10096 replaceable event meant to select one or more servers the user wants
323to upload files to. Servers are listed as `server` tags: 324to upload files to. Servers are listed as `server` tags:
324 325
325```js 326```json
326{ 327{.
327 // ...
328 "kind": 10096, 328 "kind": 10096,
329 "content": "", 329 "content": "",
330 "tags": [ 330 "tags": [
331 ["server", "https://file.server.one"], 331 ["server", "https://file.server.one"],
332 ["server", "https://file.server.two"] 332 ["server", "https://file.server.two"]
333 ] 333 ],
334 // other fields...
334} 335}
335``` 336```