|
@@ -94,14 +94,13 @@ class NewsViewModel(val apiService: ApiService, val prefHelper: PrefHelper) : Ba
|
|
|
if (!upload.isNullOrEmpty()) {
|
|
|
// Assuming 'upload' is a file path, you may need to modify this part based on your actual requirements
|
|
|
val file = File(request.upload)
|
|
|
- //val filePart = MultipartBody.Part.createFormData("upload", file.name, file.asRequestBody("multipart/form-data".toMediaTypeOrNull()))
|
|
|
- //val filePart = MultipartBody.Part.createFormData("upload", file.name, file.asRequestBody())
|
|
|
+ val filePart = MultipartBody.Part.createFormData("upload", file.name, file.asRequestBody("multipart/form-data".toMediaTypeOrNull()))
|
|
|
+// val filePart = MultipartBody.Part.createFormData("upload", file.name, file.asRequestBody())
|
|
|
|
|
|
// val file = File(request.upload)
|
|
|
// val fileRequestBody = RequestBody.create("multipart/form-data".toMediaTypeOrNull(), file)
|
|
|
// val filePart = MultipartBody.Part.createFormData("upload", file.name, fileRequestBody)
|
|
|
//
|
|
|
-// _state.value = prev().copy(isProgress = true)
|
|
|
//
|
|
|
// val requestBody = MultipartBody.Builder()
|
|
|
// .setType(MultipartBody.FORM)
|
|
@@ -115,7 +114,7 @@ class NewsViewModel(val apiService: ApiService, val prefHelper: PrefHelper) : Ba
|
|
|
_state.value = prev().copy(isProgress = true)
|
|
|
|
|
|
disposables.add(
|
|
|
- apiService.createNews(titlePart, descPart, file.asRequestBody("multipart/form-data".toMediaTypeOrNull()))
|
|
|
+ apiService.createNews(titlePart, descPart,filePart)
|
|
|
.timeout(60, TimeUnit.SECONDS)
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|