# Storage

**Setări → Stocare** (Settings → Storage) chooses where product images and uploaded files live: on the shop's own
server, or in a bucket at an S3-compatible service (AWS S3, Hetzner Object Storage, Cloudflare R2, DigitalOcean
Spaces, Backblaze B2, MinIO). Changing it needs *Manages settings*, and the page asks for your password again,
because it holds the bucket's access keys.

Files come in two kinds. **Public** files, such as product images, sit under `media/` and are shown on the site.
**Private** files, such as invoices, return documents and B2B files, sit under `private/` and open only through
links the shop checks; they are never public.

## Using a bucket

1. Create a bucket at the provider and an access key that may read and write it. Turn on versioning there: it is
   your backup for files in the bucket.
2. Make the bucket's `media/` files readable by anyone, through a bucket policy, a public domain (R2) or a CDN in
   front of it. Never make `private/` public. The safest setup is a second, fully private bucket for private files.
3. Fill in the form:
   - **Endpoint**: the provider's address, for example `https://fsn1.your-objectstorage.com` for Hetzner or
     `https://<account>.r2.cloudflarestorage.com` for R2. Leave it empty for AWS.
   - **Region**: `eu-central-1` for AWS Frankfurt, `fsn1` for Hetzner Falkenstein, `auto` for R2.
   - **Bucket** and, optionally, **Bucket pentru fișiere private** (bucket for private files).
   - **Access key** and **Secret key**. They are stored encrypted and never shown again; leave the fields empty to
     keep the saved ones.
   - **Adresa publică a bucketului** (public address): where the bucket's files can be seen, usually the CDN or the
     bucket's public domain. Images will be at this address followed by `/media/`.
   - **ACL public-read**: turn it on only if your provider uses ACLs and the bucket is not public by policy (AWS,
     Hetzner, Spaces). Leave it off for R2.
4. **Testează conexiunea** (test the connection) writes, reads and deletes a small file in both places, checks that
   the public file shows at the public address and that the private one does not. **Salvează** runs the same test
   and saves only if the bucket passes. A warning (for example a CDN that needs a moment) still lets you save.

From then on, new uploads go to the bucket.

## Moving the files you already have

Files uploaded earlier stay where they are and keep working. The **Fișiere** (files) panel counts them; **Mută
fișierele** (move the files) moves them in the background. Each file is copied and checked before the shop starts
using the new copy, so the site works normally during the move, and you can start it again at any time: files
already moved are skipped.

On the server, the same move is:

```bash
php artisan media:move --to=s3          # or --to=local to bring them back
php artisan media:move --to=s3 --queue  # one background job per file
php artisan media:move --to=s3 --keep   # leave the old copies in place
```

Switching back to the server's disk works the same way: choose **Discul acestui server**, save, and move the files
back.
