Funkwhale's current upload process is cumbersome and can be confusing for new users. Essentially, users have to know exactly where they want to put content before they've even uploaded it, and once it's uploaded it's hard to move.
To simplify this flow, the upload process should have a single entrypoint which then guides the user to the correct upload context. Rather than needing to go through a series of steps to upload each item. The proposed solution is to create a single modal for uploads that doesn't require the user to navigate to upload content to different locations.
## Feature behavior
The new feature will present an upload menu that gives users all upload options as a selectable radio menu:
1. Library (later Collections)
2. Music channel
3. Podcast channel
Once the user selects an option, they can select the target from a dropdown and start uploading straight away.
7. Funkwhale assesses if all files have the correct metadata and highlights any issues for the user to fix _with a meaningful message_. The web app keep the connection open until the API sends a response
- If the user dismisses the modal with the escape key, by clicking outside the modal, or by moving back to the previous page, _the web app must warn the user and given the option to cancel their upload or continue it in the background_
See the [interactive prototype](https://design.funkwhale.audio/#/view/e3a187f0-0f5e-11ed-adb9-fff9e854a67c?page-id=d9f9f4d0-1a7b-11ed-8551-a35b3c702efa§ion=interactions&index=0) for an overview of the behavior.
To give upload results more structure, each upload created in the web app must belong to an upload group. An upload group is a simple collection of uploads.
```{mermaid}
sequenceDiagram
Client->>+API: POST /api/v2/upload-groups
API-->>Client: 201 GUID
loop For each file
Client->>API: POST /api/v2/upload-groups/{guid}/uploads
API-->>Client: 200 Creation message
end
```
Clients may also send a file to the `/api/v2/uploads` endpoint. This endpoint accepts **only** a file with no additional metadata nor target.
### Upload group
Authenticated users may create upload groups by sending a POST request to the `/api/v2/upload-groups` endpoint with no request body.
```console
$ curl -X POST "/api/v2/upload-groups" \
-H "accept: application/json"
```
The user may optionally send a group `name` in the body of the request to give the release group a meaningful name.
```console
$ curl -X POST "/api/v2/upload-groups" \
-H "Content-type: application/json" \
-d '{"name": "My cool group"}'
```
:::{note}
If no `name` is present, the server should use the timestamp of the request as the upload group's `name`.
:::
The API should respond with the following information:
- A `201: Created` response
- The `name` of the newly created upload group
- The `guid` of the newly created upload group
- The `uploadUrl` where clients can send new uploads or query the uploads in the group
Once the server creates the upload group, the client can send files to the `/api/v2/upload-groups/{guid}/uploads` endpoint to add new uploads to the group.
This endpoint must support 2 methods controlled by the `Content-Type` header:
1. A single file as an `octet-stream`
- If the client sends an audio file as an `octet-stream`, the server is responsible for parsing the file metadata and managing the import
2. A `multipart/form-data` submission including metadata, the audio file, and an optional cover. This method enables the client to set parse and set metadata information independent of the server
If the client sends a `multipart/form-data` submission, the payload must contain:
- A `metadata` object containing **at least**
- The `title` of the uploaded file
- The `artist.name` of the artist
- An optional `target` object containing _any of the following_:
- An array of collections
- An array of channels
- A library
- The audio file
:::{important}
If the client doesn't specify a `target`, the server must implicitly add the upload to the built-in `Uploads` collection.
If the client doesn't have the capability to send a multipart request or the user prefers to simply send plain files, the file can be uploaded by sending a POST request to the `/api/v2/uploads` endpoint.
On receipt of a file, the server should respond with a `202: Accepted` response to inform the client that the server has received the file but not yet processed it. The server must then:
- Create a **daily** upload group, if none exists for the current 24 hour period
- Add the upload to the daily upload group. All uploads sent through the `/api/v2/uploads` endpoint must be assigned to the daily upload group so that users can check the upload's status in the web app
- Add the built-in **Uploads** collection as the upload's `target`
The client should then be able to query the status of a specific upload by sending a GET request to the `/api/v2/uploads/{guid}` endpoint. This endpoint must contain the information listed below.