> For the complete documentation index, see [llms.txt](https://docs.mburger.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mburger.cloud/ios-docs/admin/upload-media.md).

# Upload media

You can upload media in 2 ways:

* Uploading images, giving them names. In that case images will be converted in `jpg` (you can specify the compression quality).
* Uploading files with their URL.

To upload an image or multiple images:

```swift
let image1: UIImage = AN_IMAGE
let image2: UIImage = ANOTHER_IMAGE

// Upload a single image        
MBAdmin.uploadMediaImage(image: image1,
                         name: "Image name",
                         success: { media in

}, failure: { error in

})

// Upload multiple images
MBAdmin.uploadMediaImages(images: [image1, image2],
                          names: ["Image1", "Image2"],
                          success: { media in

}, failure: { error in

})
```

To upload files with their URLs:

```swift
let file1Url: URL = AN_URL
let file2Url: URL = ANOTHER_URL

// Upload a single file
MBAdmin.uploadMedia(media: file1Url,
                    success: { media in

                    },
                    failure: { error in

                    })

// Upload an array of files
MBAdmin.uploadMedia(media: [file1Url, file2Url],
                    success: { media in

                    },
                    failure: { error in

                    })
```
