Skip to content

Commit

Permalink
Add pre-upload step
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfranca committed Mar 29, 2024
1 parent 0275b58 commit 3110ff0
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions 95.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,40 @@ Metadata should be added using [NIP-94](94.md) or other metadata-related NIP.
Client should upload to user's "file relays", which use the [NIP-65](65.md) `f` flag.
When downloading a file uploaded with this NIP, it should search on the uploader's "file relays".

**Relays must NOT honor `kind:5` deletion events referencing file chunk events.** Deletion
is expected to be automatic when no uploader is registered (see [Pre-Upload](#pre-upload) section
to learn how to register an uploader). If an user wants to make sure a file won't be deleted, it
should become an uploader of that file.

## Pre-Upload

Before uploading `kind:1064` events of a specifc file,
user MUST publish a single `kind:1065` "Uploader" event,
which is an event authored by the **user's main pubkey**,
with empty `.content` and an `f` tag referencing the `kind:1064`
event set (the `kind:1064` event(s) `.pubkey`).

Its purpose is to register the user as an uploader of the file on a specific relay and to request permission
for uploading the file chunks.

When receiving the `kind:1065` event, relay may answer with one of the following messages and prefixes:

- `["OK", "<kind:1065-event-id>", false, "auth-required: ..."]`: Authentication is required to register an uploader;
- `["OK", "<kind:1065-event-id>", true, "uploaded: ..."]`: The corresponding `kind:1064` file chunks are already uploaded, trying to re-upload them will fail;
- `["OK", "<kind:1065-event-id>", true, "upload: Missing chunks 1, 2, 7, 10"]`: File isn't uploaded yet or incomplete, user is allowed to upload it on this ws connection;

Trying to send a `kind:1064` event before a `kind:1065` one should fail.
Sending `kind:1065` events with an identifier (pubkey) different from the previously sent `kind:1064`'s `f` tag should fail.

A `kind:5` deletion event referencing a `kind:1065` event is used to unregister the user as an uploader.

Relay may split the burden of a single file by the multiple registered uploaders. For example, when there are 2 uploaders,
a file relay may charge each of them half of the costs to host the file.

Relay should delete the `kind:1065` event if no corresponding `kind:1064` event is uploaded within a reasonable period.

Clients may download `kind:1065` events from user's file relays to list all user files.

## Download

This NIP introduces a NIP-94 `f` tag filled with the `kind:1064` pubkey, uniquely identifying the file,
Expand Down

0 comments on commit 3110ff0

Please sign in to comment.