package com.yidian.shenghuoquan.newscontent.utils

import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.MultipartBody
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File

class UploadFileUtils {
    companion object{
        fun fileToMultipartBodyPart(fileKey: String, file: File): MultipartBody.Part{
            val requestFile = file.asRequestBody("multipart/form-data".toMediaTypeOrNull())
            return MultipartBody.Part.createFormData(fileKey, file.name, requestFile)
        }
    }
}