@@ -12,16 +12,9 @@ import com.abedelazizshe.lightcompressorlibrary.VideoQuality
12
12
import com.abedelazizshe.lightcompressorlibrary.config.Configuration
13
13
import com.abedelazizshe.lightcompressorlibrary.config.SaveLocation
14
14
import com.abedelazizshe.lightcompressorlibrary.config.SharedStorageConfiguration
15
- import com.record.common.util.getVideoFrameAt1Sec
16
15
import kotlinx.coroutines.CoroutineScope
17
16
import kotlinx.coroutines.Dispatchers
18
17
import kotlinx.coroutines.launch
19
- import okhttp3.MediaType.Companion.toMediaTypeOrNull
20
- import okhttp3.OkHttpClient
21
- import okhttp3.Request
22
- import okhttp3.RequestBody
23
- import java.io.File
24
- import java.io.IOException
25
18
26
19
fun getAllVideos (
27
20
loadSize : Int ,
@@ -100,59 +93,7 @@ fun getVideoDuration(context: Context, uri: Uri): Long {
100
93
retriever.release()
101
94
}
102
95
}
103
- fun uploadFileToS3PresignedUrl (presignedUrl : String , file : File , callback : (Boolean , String ) -> Unit ) {
104
- val client = OkHttpClient ()
105
- val mediaType = " application/octet-stream" .toMediaTypeOrNull()
106
- val requestBody = RequestBody .create(mediaType, file)
107
96
108
- val request = Request .Builder ()
109
- .url(presignedUrl)
110
- .put(requestBody)
111
- .build()
112
- client.newCall(request).enqueue(
113
- object : okhttp3.Callback {
114
- override fun onFailure (call : okhttp3.Call , e : IOException ) {
115
- callback(false , " Upload failed: ${e.message} " )
116
- }
117
-
118
- override fun onResponse (call : okhttp3.Call , response : okhttp3.Response ) {
119
- if (response.isSuccessful) {
120
- callback(true , " ${response.request.url} " )
121
- } else {
122
- callback(false , " Upload failed: ${response.message} " )
123
- }
124
- }
125
- },
126
- )
127
- }
128
- fun uploadFileToS3ThumbnailPresignedUrl (context : Context , presignedUrl : String , file : File , callback : (Boolean , String ) -> Unit ) {
129
- val videoPath = file.absolutePath
130
- val outputImagePath = File (context.cacheDir, file.name)
131
- getVideoFrameAt1Sec(videoPath, outputImagePath.absolutePath)
132
- val client = OkHttpClient ()
133
- val mediaType = " application/octet-stream" .toMediaTypeOrNull()
134
- val requestBody = RequestBody .create(mediaType, outputImagePath)
135
-
136
- val request = Request .Builder ()
137
- .url(presignedUrl)
138
- .put(requestBody)
139
- .build()
140
- client.newCall(request).enqueue(
141
- object : okhttp3.Callback {
142
- override fun onFailure (call : okhttp3.Call , e : IOException ) {
143
- callback(false , " Upload failed: ${e.message} " )
144
- }
145
-
146
- override fun onResponse (call : okhttp3.Call , response : okhttp3.Response ) {
147
- if (response.isSuccessful) {
148
- callback(true , " ${response.request.url} " )
149
- } else {
150
- callback(false , " Upload failed: ${response.message} " )
151
- }
152
- }
153
- },
154
- )
155
- }
156
97
fun formatDuration (durationMillis : Long ): String {
157
98
val minutes = (durationMillis / 1000 ) / 60
158
99
val seconds = (durationMillis / 1000 ) % 60
0 commit comments