com.cloudinary.config.ApiConfig.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-url-gen Show documentation
Show all versions of kotlin-url-gen Show documentation
Cloudinary is a cloud service that offers a solution to a web application's entire image management pipeline. Upload images to the cloud. Automatically perform smart image resizing, cropping and conversion without installing any complex software. Integrate Facebook or Twitter profile image extraction in a snap, in any dimension and style to match your websiteâs graphics requirements. Images are seamlessly delivered through a fast CDN, and much much more. This Java library allows to easily integrate with Cloudinary in Kotlin applications.
The newest version!
package com.cloudinary.config
const val DEFAULT_CHUNK_SIZE = 20_000_000 // bytes
const val DEFAULT_READ_TIMEOUT = 0
const val DEFAULT_CONNECTION_TIMEOUT = 60 // seconds
const val DEFAULT_UPLOAD_PREFIX = "https://api.cloudinary.com"
const val UPLOAD_PREFIX = "upload_prefix"
const val CHUNK_SIZE = "chunk_size"
const val READ_TIMEOUT = "read_timeout"
const val CONNECT_TIMEOUT = "connect_timeout"
const val CALLBACK_URL = "callback_url"
interface IApiConfig {
val uploadPrefix: String
val chunkSize: Int
val readTimeout: Int
val connectionTimeout: Int
val callbackUrl: String?
}
data class ApiConfig(
override val uploadPrefix: String = DEFAULT_UPLOAD_PREFIX,
override val chunkSize: Int = DEFAULT_CHUNK_SIZE,
override val readTimeout: Int = DEFAULT_READ_TIMEOUT,
override val connectionTimeout: Int = DEFAULT_CONNECTION_TIMEOUT,
override val callbackUrl: String? = null
) : IApiConfig {
constructor(params: Map) : this(
uploadPrefix = params[UPLOAD_PREFIX]?.toString() ?: DEFAULT_UPLOAD_PREFIX,
chunkSize = params.getInt(CHUNK_SIZE) ?: DEFAULT_CHUNK_SIZE,
readTimeout = params.getInt(READ_TIMEOUT) ?: DEFAULT_READ_TIMEOUT,
connectionTimeout = params.getInt(CONNECT_TIMEOUT) ?: DEFAULT_CONNECTION_TIMEOUT,
callbackUrl = params[CALLBACK_URL]?.toString()
)
}