|
| 1 | +--- |
| 2 | +title: Uploads |
| 3 | +sidebar_position: 3 |
| 4 | +--- |
| 5 | + |
| 6 | +This page contains information about the `/upload` endpoint, which is used to upload avatars, backgrounds, audios, custom cursors, and custom fonts. |
| 7 | + |
| 8 | +## Upload an avatar |
| 9 | + |
| 10 | +Upload a new avatar, and replace the current one if you have one. |
| 11 | + |
| 12 | +### Request |
| 13 | + |
| 14 | +```http request |
| 15 | +POST /api/upload/avatar |
| 16 | +Content-Type: multipart/form-data |
| 17 | +
|
| 18 | +file: <file> |
| 19 | +``` |
| 20 | + |
| 21 | +### Example Response |
| 22 | + |
| 23 | +Returns a 201 status on success, and the avatar URL in the response body. |
| 24 | + |
| 25 | +```json |
| 26 | +{ |
| 27 | + "url": "https://cdn.miwa.lol/avatars/c950e071-75fd-4212-aab7-387fa5bda67b.png" |
| 28 | +} |
| 29 | +``` |
| 30 | + |
| 31 | +## Upload a background |
| 32 | + |
| 33 | +Upload a new background, and replace the current one if you have one. It can be an image or a video. |
| 34 | + |
| 35 | +:::note |
| 36 | + |
| 37 | +Images will be converted to WebP format losslessly that can reduce the file size, which means faster loading times. |
| 38 | + |
| 39 | +::: |
| 40 | + |
| 41 | +### Request |
| 42 | + |
| 43 | +```http request |
| 44 | +POST /api/upload/background |
| 45 | +Content-Type: multipart/form-data |
| 46 | +
|
| 47 | +file: <file> |
| 48 | +``` |
| 49 | + |
| 50 | +### Example Response |
| 51 | + |
| 52 | +Returns a 201 status on success, and the background URL in the response body. |
| 53 | + |
| 54 | +```json |
| 55 | +{ |
| 56 | + "url": "https://cdn.miwa.lol/backgrounds/8162f53e-d186-41b2-a008-75551a9c1b0a.webp" |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +## Upload an audio |
| 61 | + |
| 62 | +Upload a new audio. It will be added to your audio list. |
| 63 | + |
| 64 | +### Request |
| 65 | + |
| 66 | +:::note |
| 67 | + |
| 68 | +The cover is optional, but it's recommended to provide one. It will be displayed in the audio player. |
| 69 | + |
| 70 | +::: |
| 71 | + |
| 72 | +```http request |
| 73 | +POST /api/upload/audio |
| 74 | +Content-Type: multipart/form-data |
| 75 | +
|
| 76 | +file: <file> |
| 77 | +cover: <file> (optional) |
| 78 | +name: <string> |
| 79 | +``` |
| 80 | + |
| 81 | +### Example Response |
| 82 | + |
| 83 | +Returns a 201 status on success, and the audio object in the response body. |
| 84 | + |
| 85 | +```json |
| 86 | +{ |
| 87 | + "id": "2a7438fa-2821-47bb-8d00-ffa68628c7cd", |
| 88 | + "name": "A very cool music", |
| 89 | + "duration": 120, // In seconds |
| 90 | + "cover": "7c6d9e78-3ced-4f60-9357-19db54d19dfe" // "null" if you didn't provide a cover |
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +:::tip |
| 95 | + |
| 96 | +Covers URLs are just `https://cdn.miwa.lol/audios-covers/:id.png`, where `:id` is the cover ID (the one in the response). |
| 97 | + |
| 98 | +::: |
| 99 | + |
| 100 | +## Update an audio |
| 101 | + |
| 102 | +Update an audio by its ID. |
| 103 | + |
| 104 | +### Request |
| 105 | + |
| 106 | +```http request |
| 107 | +PATCH /api/upload/audio/:id |
| 108 | +Content-Type: application/json |
| 109 | +``` |
| 110 | + |
| 111 | +Example body: |
| 112 | +```json |
| 113 | +{ |
| 114 | + // You can only update the name |
| 115 | + "name": "A very cool music" |
| 116 | +} |
| 117 | +``` |
| 118 | + |
| 119 | +### Example Response |
| 120 | + |
| 121 | +Returns the updated audio object. |
| 122 | + |
| 123 | +```json |
| 124 | +{ |
| 125 | + "id": "2a7438fa-2821-47bb-8d00-ffa68628c7cd", |
| 126 | + "name": "A very cool music", |
| 127 | + "duration": 120, |
| 128 | + "cover": "7c6d9e78-3ced-4f60-9357-19db54d19dfe" |
| 129 | +} |
| 130 | +``` |
| 131 | + |
| 132 | +## Delete an audio |
| 133 | + |
| 134 | +Delete an audio by its ID. |
| 135 | + |
| 136 | +### Request |
| 137 | + |
| 138 | +```http request |
| 139 | +DELETE /api/upload/audio/:id |
| 140 | +``` |
| 141 | + |
| 142 | +### Example Response |
| 143 | + |
| 144 | +Returns: |
| 145 | +* a 204 status on success. |
| 146 | +* a 404 status if the audio doesn't exist. |
| 147 | +* a 403 status if the audio doesn't belong to you. |
| 148 | + |
| 149 | +## Upload a custom cursor |
| 150 | + |
| 151 | +Upload a new custom cursor, and replace the current one if you have one. |
| 152 | + |
| 153 | +### Request |
| 154 | + |
| 155 | +```http request |
| 156 | +POST /api/upload/cursor |
| 157 | +Content-Type: multipart/form-data |
| 158 | +
|
| 159 | +file: <file> |
| 160 | +``` |
| 161 | + |
| 162 | +### Example Response |
| 163 | + |
| 164 | +Returns a 201 status on success, and the cursor URL in the response body. |
| 165 | + |
| 166 | +```json |
| 167 | +{ |
| 168 | + "url": "https://cdn.miwa.lol/cursors/de9bec09-f9d4-42c4-9e75-834bc5e3bdfb.cur" |
| 169 | +} |
| 170 | +``` |
| 171 | + |
| 172 | +## Upload a custom font |
| 173 | + |
| 174 | +:::info |
| 175 | + |
| 176 | +This endpoint is only available to Premium users. |
| 177 | + |
| 178 | +::: |
| 179 | + |
| 180 | +Upload a new custom font, and replace the current one if you have one. |
| 181 | + |
| 182 | +### Request |
| 183 | + |
| 184 | +```http request |
| 185 | +POST /api/upload/font |
| 186 | +Content-Type: multipart/form-data |
| 187 | +
|
| 188 | +file: <file> |
| 189 | +``` |
| 190 | + |
| 191 | +### Example Response |
| 192 | + |
| 193 | +Returns a 201 status on success, and the font URL in the response body. |
| 194 | + |
| 195 | +```json |
| 196 | +{ |
| 197 | + "url": "https://cdn.miwa.lol/fonts/b3f66781-a5c8-4303-a6a3-807731b2ab93.ttf" |
| 198 | +} |
| 199 | +``` |
0 commit comments