Как подключить свою музыку из Cloudflare R2How to connect your music in Cloudflare R2
Что это и сколько стоитWhat it is and what it costs
Cloudflare R2 — облачное хранилище файлов. Вы кладёте туда свою музыку, Melobox её играет и скачивает.Cloudflare R2 is cloud file storage. You put your music there; Melobox plays and downloads it.
- Бесплатно каждый месяц: 10 ГБ хранения, 1 млн операций записи и листинга (класс A), 10 млн операций чтения (класс B).Free every month: 10 GB of storage, 1 million write/list operations (class A), 10 million read operations (class B).
- Скачивание (трафик) — бесплатно всегда.Downloading (egress) is always free.
- Сверх 10 ГБ: $0.015 за ГБ в месяц. 50 ГБ музыки ≈ $0.60 в месяц.Beyond 10 GB: $0.015 per GB per month. 50 GB of music ≈ $0.60 a month.
- Бесплатный лимит действует только для класса хранения Standard.The free tier applies to the Standard storage class only.
1. Аккаунт Cloudflare1. A Cloudflare account
Зайдите на dash.cloudflare.com и зарегистрируйтесь (почта и пароль) или войдите. Подтвердите почту по ссылке из письма.Go to dash.cloudflare.com and sign up (email and password) or log in. Confirm your email from the link you receive.
2. Включите R22. Enable R2
В левом меню: Storage & databases → R2 → Overview. Если R2 ещё не включён, пройдите оформление (checkout): тариф — бесплатный, оплата только сверх лимита.In the left menu: Storage & databases → R2 → Overview. If R2 is not enabled yet, go through checkout: the plan is free, you pay only beyond the free tier.
3. Создайте бакет3. Create a bucket
- R2 → Overview → Create bucket.R2 → Overview → Create bucket.
- Bucket name — например,
melobox-music: маленькие латинские буквы, цифры и дефис, 3–63 символа.Bucket name — for examplemelobox-music: lowercase letters, digits and hyphens, 3–63 characters. - Location — Automatic. Не выбирайте Specify jurisdiction без необходимости: её потом не изменить, а адрес такого бакета другой.Location — Automatic. Don't pick Specify jurisdiction unless you need it: it can't be changed later and such a bucket has a different address.
- Default storage class — Standard. Нажмите Create bucket.Default storage class — Standard. Click Create bucket.
Бакет закрытый — так и оставьте. Публичный доступ (r2.dev, свой домен) Melobox не нужен: иначе вашу музыку сможет скачать любой, кто узнает адрес.The bucket is private — keep it that way. Melobox doesn't need public access (r2.dev, a custom domain): with it, anyone who learns the address could download your music.
4. Загрузите музыку4. Upload your music
Удобнее всего раскладывать так: Исполнитель/Альбом/01 - Название.flac — тогда даже файлы без тегов попадут в правильный альбом. Обложку можно положить рядом файлом cover.jpg.The easiest layout is Artist/Album/01 - Title.flac — then even untagged files land in the right album. A cover can sit next to them as cover.jpg.
Немного файлов — через браузер: откройте бакет → Upload, перетащите файлы; папки создаются кнопкой Create folder.A few files — in the browser: open the bucket → Upload and drop the files; Create folder makes folders.
Много файлов — программой rclone (версия 1.59 или новее) на компьютере. Ей нужен отдельный ключ с правом записи (как в шаге 5, но с разрешением Object Read & Write). Этот ключ храните только на компьютере и в телефон не вводите.Many files — with rclone (1.59 or newer) on a computer. It needs a separate key with write access (as in step 5, but with Object Read & Write). Keep that key on the computer only; never enter it on the phone.
[r2] type = s3 provider = Cloudflare access_key_id = <Access Key ID> secret_access_key = <Secret Access Key> endpoint = https://<account-id>.r2.cloudflarestorage.com acl = private no_check_bucket = true
Загрузка папки:Upload a folder: rclone copy "D:\Music" r2:melobox-music --progress
5. Ключ только на чтение для телефона5. A read-only key for the phone
Melobox ничего не пишет в облако, поэтому ему хватает ключа, который умеет только читать. Если телефон потеряется, таким ключом нельзя удалить или испортить музыку.Melobox never writes to the cloud, so a key that can only read is all it needs. If the phone is lost, such a key can't delete or damage your music.
- R2 → Overview, блок Account Details → Manage рядом с API Tokens.R2 → Overview, the Account Details box → Manage next to API Tokens.
- Create Account API token, имя — например,
melobox-phone.Create Account API token, name it e.g.melobox-phone. - Permissions — Object Read only.Permissions — Object Read only.
- Specify bucket(s) — Apply to specific buckets only, ваш бакет.Specify bucket(s) — Apply to specific buckets only, your bucket.
- Нажмите Create Account API token.Click Create Account API token.
| В CloudflareIn Cloudflare | Что этоWhat it is |
|---|---|
| Access Key ID | Логин ключа (32 символа)The key's login (32 characters) |
| Secret Access Key | Пароль ключа (64 символа)The key's password (64 characters) |
EndpointEndpoint https://<id>.r2.cloudflarestorage.com | Адрес вашего хранилищаYour storage address |
Значение Token value Melobox не нужно.Melobox doesn't need the Token value.
6. Подключите Melobox6. Connect Melobox
Проще всего — QR-кодом. Откройте на компьютере страницу подключения, вставьте адрес, бакет, Access Key ID и Secret Access Key, нажмите «Показать QR-код». В Melobox: Настройки → Облако → Сканировать QR-код. Страница работает прямо в браузере и ничего никуда не отправляет.Easiest — with a QR code. On your computer open the connect page, paste the address, bucket, Access Key ID and Secret Access Key, and click “Show QR code”. In Melobox: Settings → Cloud → Scan QR code. The page runs in your browser and sends nothing anywhere.
Или вручную: скопируйте значение в Cloudflare и нажмите в Melobox «Вставить» — оно само попадёт в нужное поле. Нажмите «Проверить и сохранить»: Melobox сохранит ключи, только если пробный запрос прошёл. Ключи хранятся на телефоне в зашифрованном виде и не попадают в резервные копии.Or by hand: copy a value in Cloudflare and tap “Paste” in Melobox — it goes to the right field. Tap “Check and save”: Melobox stores the keys only if a test request works. Keys are encrypted on the phone and never go into backups.
Сразу начнётся обновление из облака: Melobox прочитает теги файлов, не скачивая их целиком, и музыка появится в библиотеке со значком ☁.The cloud refresh starts right away: Melobox reads the files' tags without downloading them, and the music appears in the library marked ☁.
Если что-то не такTroubleshooting
| СообщениеMessage | Что сделатьWhat to do |
|---|---|
| «Неверный ключ или секрет…»“Wrong key or secret…” | Проверьте, что ключ скопирован без пробелов. Если секрет потерян — создайте новый ключ, старый удалите.Check the key was copied without spaces. If the secret is lost, create a new key and delete the old one. |
| «Такого бакета нет»“No such bucket” | Имя бакета — маленькими буквами, как в Cloudflare. Для бакета с юрисдикцией EU адрес — https://<id>.eu.r2.cloudflarestorage.com.The bucket name is lowercase, exactly as in Cloudflare. For an EU-jurisdiction bucket the address is https://<id>.eu.r2.cloudflarestorage.com. |
| «Не удаётся связаться с облаком»“Can't reach the cloud” | Проверьте интернет и адрес.Check the internet connection and the address. |
| Треки не появилисьNo tracks appear | В бакете должны быть аудиофайлы: mp3, flac, ogg, opus, m4a (AAC и ALAC), wav. Нажмите «Обновить из облака».The bucket must hold audio files: mp3, flac, ogg, opus, m4a (AAC and ALAC), wav. Tap “Refresh from cloud”. |
Как отозвать доступ телефона: R2 → Overview → Manage (API Tokens) → удалите ключ melobox-phone. Музыка в облаке не пострадает.To revoke the phone's access: R2 → Overview → Manage (API Tokens) → delete the melobox-phone key. The music in the cloud stays.
Поделиться коллекцией: создайте для другого человека отдельный ключ только на чтение и покажите ему QR-код. Отозвать доступ — удалить этот ключ.Sharing your collection: make a separate read-only key for the other person and show them the QR code. To revoke access, delete that key.