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:

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:

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

                    })

Last updated