com.avito.http.Files.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of okhttp Show documentation
Show all versions of okhttp Show documentation
Collection of infrastructure libraries and gradle plugins of Avito Android project
@file:JvmName("FileUtils")
package com.avito.http
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.MultipartBody
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
public fun File.convertToImageMultipart(
name: String = "image",
filename: String = "image"
): MultipartBody.Part {
return MultipartBody.Part.createFormData(
name,
filename,
this.asRequestBody(MEDIA_TYPE_IMAGE)
)
}
private val MEDIA_TYPE_IMAGE = "image/*".toMediaType()