react-native-compressor 1.8.10 → 1.8.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -12
- package/android/build.gradle +0 -1
- package/android/src/main/java/com/reactnativecompressor/CompressorModule.kt +3 -1
- package/android/src/main/java/com/reactnativecompressor/Image/ImageCompressor.kt +56 -23
- package/android/src/main/java/com/reactnativecompressor/Image/ImageCompressorOptions.kt +2 -0
- package/android/src/main/java/com/reactnativecompressor/Utils/MediaCache.kt +15 -0
- package/android/src/main/java/com/reactnativecompressor/Utils/Uploader.kt +152 -91
- package/android/src/main/java/com/reactnativecompressor/Utils/UploaderHelper.kt +121 -0
- package/android/src/main/java/com/reactnativecompressor/Utils/Utils.kt +14 -0
- package/ios/Image/ImageCompressor.swift +53 -41
- package/ios/Image/ImageCompressorOptions.swift +3 -0
- package/ios/Utils/MediaCache.swift +20 -0
- package/ios/Utils/Uploader.swift +123 -4
- package/ios/Utils/Utils.swift +20 -0
- package/lib/commonjs/Image/index.js.map +1 -1
- package/lib/commonjs/index.js +15 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/Uploader.js +16 -1
- package/lib/commonjs/utils/Uploader.js.map +1 -1
- package/lib/module/Image/index.js.map +1 -1
- package/lib/module/index.js +5 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/Uploader.js +13 -0
- package/lib/module/utils/Uploader.js.map +1 -1
- package/lib/typescript/Image/index.d.ts +4 -0
- package/lib/typescript/Image/index.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +5 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/Uploader.d.ts +12 -11
- package/lib/typescript/utils/Uploader.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Image/index.tsx +4 -0
- package/src/index.tsx +6 -0
- package/src/utils/Uploader.tsx +14 -14
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
package com.reactnativecompressor.Utils
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap
|
|
4
|
+
import okhttp3.RequestBody
|
|
5
|
+
import okio.Buffer
|
|
6
|
+
import okio.BufferedSink
|
|
7
|
+
import okio.ForwardingSink
|
|
8
|
+
import okio.IOException
|
|
9
|
+
import okio.Sink
|
|
10
|
+
import okio.buffer
|
|
11
|
+
|
|
12
|
+
interface Record
|
|
13
|
+
annotation class Field(val key: String = "")
|
|
14
|
+
interface Enumerable
|
|
15
|
+
|
|
16
|
+
@FunctionalInterface
|
|
17
|
+
fun interface RequestBodyDecorator {
|
|
18
|
+
fun decorate(requestBody: RequestBody): RequestBody
|
|
19
|
+
}
|
|
20
|
+
enum class EncodingType(val value: String) : Enumerable {
|
|
21
|
+
UTF8("utf8"),
|
|
22
|
+
BASE64("base64")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
enum class UploadType(val value: Int) : Enumerable {
|
|
26
|
+
BINARY_CONTENT(0),
|
|
27
|
+
MULTIPART(1)
|
|
28
|
+
}
|
|
29
|
+
data class UploaderOptions(
|
|
30
|
+
val headers: Map<String, String>?,
|
|
31
|
+
val httpMethod: HttpMethod = HttpMethod.POST,
|
|
32
|
+
val uploadType: UploadType,
|
|
33
|
+
val fieldName: String?,
|
|
34
|
+
val mimeType: String?,
|
|
35
|
+
val parameters: Map<String, String>?,
|
|
36
|
+
val uuid:String,
|
|
37
|
+
val url:String
|
|
38
|
+
) : Record
|
|
39
|
+
|
|
40
|
+
enum class HttpMethod(val value: String) : Enumerable {
|
|
41
|
+
POST("POST"),
|
|
42
|
+
PUT("PUT"),
|
|
43
|
+
PATCH("PATCH")
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
internal class UploaderOkHttpNullException :
|
|
47
|
+
CodedException("okHttpClient is null")
|
|
48
|
+
internal class CookieHandlerNotFoundException :
|
|
49
|
+
CodedException("Failed to find CookieHandler")
|
|
50
|
+
interface CodedThrowable {
|
|
51
|
+
val code: String?
|
|
52
|
+
val message: String?
|
|
53
|
+
}
|
|
54
|
+
abstract class CodedException : Exception, CodedThrowable {
|
|
55
|
+
constructor(message: String?) : super(message)
|
|
56
|
+
constructor(cause: Throwable?) : super(cause)
|
|
57
|
+
constructor(message: String?, cause: Throwable?) : super(message, cause)
|
|
58
|
+
|
|
59
|
+
override val code: String
|
|
60
|
+
get() = "ERR_UNSPECIFIED_ANDROID_EXCEPTION"
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@FunctionalInterface
|
|
64
|
+
interface CountingRequestListener {
|
|
65
|
+
fun onProgress(bytesWritten: Long, contentLength: Long)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@FunctionalInterface
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
private class CountingSink(
|
|
72
|
+
sink: Sink,
|
|
73
|
+
private val requestBody: RequestBody,
|
|
74
|
+
private val progressListener: CountingRequestListener
|
|
75
|
+
) : ForwardingSink(sink) {
|
|
76
|
+
private var bytesWritten = 0L
|
|
77
|
+
|
|
78
|
+
override fun write(source: Buffer, byteCount: Long) {
|
|
79
|
+
super.write(source, byteCount)
|
|
80
|
+
|
|
81
|
+
bytesWritten += byteCount
|
|
82
|
+
progressListener.onProgress(bytesWritten, requestBody.contentLength())
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
class CountingRequestBody(
|
|
87
|
+
private val requestBody: RequestBody,
|
|
88
|
+
private val progressListener: CountingRequestListener
|
|
89
|
+
) : RequestBody() {
|
|
90
|
+
override fun contentType() = requestBody.contentType()
|
|
91
|
+
|
|
92
|
+
@Throws(IOException::class)
|
|
93
|
+
override fun contentLength() = requestBody.contentLength()
|
|
94
|
+
|
|
95
|
+
override fun writeTo(sink: BufferedSink) {
|
|
96
|
+
val countingSink = CountingSink(sink, this, progressListener)
|
|
97
|
+
|
|
98
|
+
val bufferedSink = countingSink.buffer()
|
|
99
|
+
requestBody.writeTo(bufferedSink)
|
|
100
|
+
bufferedSink.flush()
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
fun convertReadableMapToUploaderOptions(options: ReadableMap): UploaderOptions {
|
|
106
|
+
val headers = options.getMap("headers")?.toHashMap() as? Map<String, String>
|
|
107
|
+
val httpMethod = HttpMethod.valueOf(options.getString("httpMethod") ?: "POST")
|
|
108
|
+
val uploadTypeInt = options.getInt("uploadType")
|
|
109
|
+
val uploadType = when (uploadTypeInt) {
|
|
110
|
+
UploadType.BINARY_CONTENT.value -> UploadType.BINARY_CONTENT
|
|
111
|
+
UploadType.MULTIPART.value -> UploadType.MULTIPART
|
|
112
|
+
else -> UploadType.BINARY_CONTENT // Provide a default value or handle the case as needed
|
|
113
|
+
}
|
|
114
|
+
val fieldName = options.getString("fieldName")?: "file"
|
|
115
|
+
val mimeType = options.getString("mimeType")?: ""
|
|
116
|
+
val parameters = options.getMap("parameters")?.toHashMap() as? Map<String, String>
|
|
117
|
+
val uuid = options.getString("uuid") ?: ""
|
|
118
|
+
val url = options.getString("url") ?: ""
|
|
119
|
+
|
|
120
|
+
return UploaderOptions(headers, httpMethod, uploadType, fieldName, mimeType, parameters, uuid, url)
|
|
121
|
+
}
|
|
@@ -15,6 +15,7 @@ import java.io.IOException
|
|
|
15
15
|
import java.net.HttpURLConnection
|
|
16
16
|
import java.net.URL
|
|
17
17
|
import java.util.UUID
|
|
18
|
+
import java.util.regex.Pattern
|
|
18
19
|
|
|
19
20
|
object Utils {
|
|
20
21
|
private const val TAG = "react-native-compessor"
|
|
@@ -134,6 +135,19 @@ object Utils {
|
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
|
|
138
|
+
fun slashifyFilePath(path: String?): String? {
|
|
139
|
+
return if (path == null) {
|
|
140
|
+
null
|
|
141
|
+
} else if (path.startsWith("file:///")) {
|
|
142
|
+
path
|
|
143
|
+
} else if (path.startsWith("/")) {
|
|
144
|
+
path.replaceFirst("^/+".toRegex(), "file:///")
|
|
145
|
+
}else {
|
|
146
|
+
// Ensure leading schema with a triple slash
|
|
147
|
+
Pattern.compile("^file:/*").matcher(path).replaceAll("file:///")
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
137
151
|
fun addLog(log: String) {
|
|
138
152
|
Log.d(AudioCompressor.TAG, log)
|
|
139
153
|
}
|
|
@@ -100,20 +100,40 @@ class ImageCompressor {
|
|
|
100
100
|
}
|
|
101
101
|
return UIImage()
|
|
102
102
|
}
|
|
103
|
+
|
|
104
|
+
static func isCompressedSizeLessThanActualFile(sourceFileUrl: String,compressedFileUrl: String)-> Bool {
|
|
105
|
+
let sourceVideoURL = URL(string: sourceFileUrl)
|
|
106
|
+
let sourcefileSize:Double=Utils.getfileSizeInBytes(forURL:sourceVideoURL!)
|
|
107
|
+
|
|
108
|
+
let compressedVideoURL = URL(string: compressedFileUrl)
|
|
109
|
+
let compressedfileSize:Double=Utils.getfileSizeInBytes(forURL:compressedVideoURL!)
|
|
110
|
+
|
|
111
|
+
if(compressedfileSize<=sourcefileSize)
|
|
112
|
+
{
|
|
113
|
+
return true
|
|
114
|
+
}
|
|
115
|
+
return false
|
|
116
|
+
}
|
|
103
117
|
|
|
104
118
|
|
|
105
|
-
static func
|
|
119
|
+
static func writeImage(_ image: UIImage, output: Int, quality: Float, outputExtension: String, isBase64: Bool,disablePngTransparency:Bool,isEnableAutoCompress:Bool,actualImagePath:String)-> String{
|
|
106
120
|
var data: Data
|
|
107
121
|
var exception: NSException?
|
|
108
|
-
|
|
109
122
|
switch OutputType(rawValue: output)! {
|
|
110
123
|
case .jpg:
|
|
111
124
|
data = image.jpegData(compressionQuality: CGFloat(quality))!
|
|
112
125
|
case .png:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
126
|
+
if(disablePngTransparency)
|
|
127
|
+
{
|
|
128
|
+
data = image.jpegData(compressionQuality: CGFloat(quality))!
|
|
129
|
+
let compressedImage = UIImage(data: data)
|
|
130
|
+
data = compressedImage!.pngData()!
|
|
131
|
+
}
|
|
132
|
+
else
|
|
133
|
+
{
|
|
134
|
+
data=image.pngData()!
|
|
135
|
+
}
|
|
136
|
+
|
|
117
137
|
}
|
|
118
138
|
|
|
119
139
|
if isBase64 {
|
|
@@ -123,17 +143,35 @@ class ImageCompressor {
|
|
|
123
143
|
do {
|
|
124
144
|
try data.write(to: URL(fileURLWithPath: filePath), options: .atomic)
|
|
125
145
|
let returnablePath = makeValidUri(filePath)
|
|
146
|
+
if(isEnableAutoCompress==true)
|
|
147
|
+
{
|
|
148
|
+
if(self.isCompressedSizeLessThanActualFile(sourceFileUrl: actualImagePath,compressedFileUrl: returnablePath))
|
|
149
|
+
{
|
|
150
|
+
return returnablePath
|
|
151
|
+
}
|
|
152
|
+
else
|
|
153
|
+
{
|
|
154
|
+
MediaCache.deleteFile(atPath:returnablePath)
|
|
155
|
+
return actualImagePath
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
126
159
|
return returnablePath
|
|
160
|
+
|
|
127
161
|
} catch {
|
|
128
162
|
exception = NSException(name: NSExceptionName(rawValue: "file_error"), reason: "Error writing file", userInfo: nil)
|
|
129
163
|
exception?.raise()
|
|
130
164
|
}
|
|
131
165
|
}
|
|
132
|
-
|
|
133
166
|
return ""
|
|
134
167
|
}
|
|
135
168
|
|
|
136
169
|
|
|
170
|
+
static func manualCompress(_ image: UIImage, output: Int, quality: Float, outputExtension: String, isBase64: Bool,disablePngTransparency:Bool,actualImagePath:String) -> String {
|
|
171
|
+
return writeImage(image, output: output, quality: quality, outputExtension: outputExtension, isBase64: isBase64, disablePngTransparency: disablePngTransparency,isEnableAutoCompress: false,actualImagePath: actualImagePath)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
137
175
|
static func scaleAndRotateImage(_ image: UIImage) -> UIImage {
|
|
138
176
|
if image.imageOrientation == .up {
|
|
139
177
|
return image
|
|
@@ -215,7 +253,7 @@ class ImageCompressor {
|
|
|
215
253
|
let outputExtension = ImageCompressorOptions.getOutputInString(options.output)
|
|
216
254
|
let resizedImage = ImageCompressor.manualResize(_image, maxWidth: options.maxWidth, maxHeight: options.maxHeight)
|
|
217
255
|
let isBase64 = options.returnableOutputType == .rbase64
|
|
218
|
-
return ImageCompressor.manualCompress(resizedImage, output: options.output.rawValue, quality: options.quality, outputExtension: outputExtension, isBase64: isBase64)
|
|
256
|
+
return ImageCompressor.manualCompress(resizedImage, output: options.output.rawValue, quality: options.quality, outputExtension: outputExtension, isBase64: isBase64,disablePngTransparency: options.disablePngTransparency,actualImagePath: imagePath)
|
|
219
257
|
} else {
|
|
220
258
|
exception = NSException(name: NSExceptionName(rawValue: "unsupported_value"), reason: "Unsupported value type.", userInfo: nil)
|
|
221
259
|
exception?.raise()
|
|
@@ -228,11 +266,11 @@ class ImageCompressor {
|
|
|
228
266
|
static func autoCompressHandler(_ imagePath: String, options: ImageCompressorOptions) -> String {
|
|
229
267
|
var exception: NSException?
|
|
230
268
|
var image = ImageCompressor.loadImage(imagePath)
|
|
231
|
-
|
|
269
|
+
|
|
232
270
|
if var image = image {
|
|
233
271
|
image = ImageCompressor.scaleAndRotateImage(image)
|
|
234
272
|
let outputExtension = ImageCompressorOptions.getOutputInString(options.output)
|
|
235
|
-
|
|
273
|
+
|
|
236
274
|
var actualHeight = image.size.height
|
|
237
275
|
var actualWidth = image.size.width
|
|
238
276
|
let maxHeight: CGFloat = CGFloat(options.maxHeight)
|
|
@@ -240,7 +278,7 @@ class ImageCompressor {
|
|
|
240
278
|
var imgRatio = actualWidth / actualHeight
|
|
241
279
|
let maxRatio = maxWidth / maxHeight
|
|
242
280
|
let compressionQuality: CGFloat = CGFloat(options.quality)
|
|
243
|
-
|
|
281
|
+
|
|
244
282
|
if actualHeight > maxHeight || actualWidth > maxWidth {
|
|
245
283
|
if imgRatio < maxRatio {
|
|
246
284
|
imgRatio = maxHeight / actualHeight
|
|
@@ -255,42 +293,16 @@ class ImageCompressor {
|
|
|
255
293
|
actualWidth = maxWidth
|
|
256
294
|
}
|
|
257
295
|
}
|
|
258
|
-
|
|
296
|
+
|
|
259
297
|
let rect = CGRect(x: 0.0, y: 0.0, width: actualWidth, height: actualHeight)
|
|
260
298
|
UIGraphicsBeginImageContext(rect.size)
|
|
261
299
|
image.draw(in: rect)
|
|
300
|
+
let isBase64 = options.returnableOutputType == .rbase64
|
|
301
|
+
|
|
262
302
|
if let img = UIGraphicsGetImageFromCurrentImageContext() {
|
|
263
|
-
|
|
264
|
-
switch OutputType(rawValue: options.output.rawValue)! {
|
|
265
|
-
case .jpg:
|
|
266
|
-
imageData = img.jpegData(compressionQuality: compressionQuality)!
|
|
267
|
-
case .png:
|
|
268
|
-
imageData = img.jpegData(compressionQuality: compressionQuality)!
|
|
269
|
-
let compressedImage = UIImage(data: imageData)
|
|
270
|
-
imageData = compressedImage!.pngData()!
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
UIGraphicsEndImageContext()
|
|
274
|
-
let isBase64 = options.returnableOutputType == .rbase64
|
|
275
|
-
if isBase64 {
|
|
276
|
-
return imageData.base64EncodedString(options: [])
|
|
277
|
-
} else {
|
|
278
|
-
let filePath = Utils.generateCacheFilePath(outputExtension)
|
|
279
|
-
do {
|
|
280
|
-
try imageData.write(to: URL(fileURLWithPath: filePath), options: .atomic)
|
|
281
|
-
let returnablePath = ImageCompressor.makeValidUri(filePath)
|
|
282
|
-
return returnablePath
|
|
283
|
-
} catch {
|
|
284
|
-
exception = NSException(name: NSExceptionName(rawValue: "file_error"), reason: "Error writing file", userInfo: nil)
|
|
285
|
-
exception?.raise()
|
|
286
|
-
}
|
|
287
|
-
}
|
|
303
|
+
return writeImage(img, output: options.output.rawValue, quality: Float(compressionQuality), outputExtension: outputExtension, isBase64: isBase64, disablePngTransparency: options.disablePngTransparency,isEnableAutoCompress: true,actualImagePath: imagePath)
|
|
288
304
|
}
|
|
289
|
-
} else {
|
|
290
|
-
exception = NSException(name: NSExceptionName(rawValue: "unsupported_value"), reason: "Unsupported value type.", userInfo: nil)
|
|
291
|
-
exception?.raise()
|
|
292
305
|
}
|
|
293
|
-
|
|
294
306
|
return ""
|
|
295
307
|
}
|
|
296
308
|
|
|
@@ -44,6 +44,8 @@ class ImageCompressorOptions: NSObject {
|
|
|
44
44
|
options.parseReturnableOutput(value as? String)
|
|
45
45
|
case "uuid":
|
|
46
46
|
options.uuid = value as? String
|
|
47
|
+
case "disablePngTransparency":
|
|
48
|
+
options.disablePngTransparency = value as? Bool ?? false
|
|
47
49
|
default:
|
|
48
50
|
break
|
|
49
51
|
}
|
|
@@ -65,6 +67,7 @@ class ImageCompressorOptions: NSObject {
|
|
|
65
67
|
var output: OutputType = .jpg
|
|
66
68
|
var returnableOutputType: ReturnableOutputType = .ruri
|
|
67
69
|
var uuid: String?
|
|
70
|
+
var disablePngTransparency: Bool = false
|
|
68
71
|
|
|
69
72
|
override init() {
|
|
70
73
|
super.init()
|
|
@@ -45,4 +45,24 @@ class MediaCache {
|
|
|
45
45
|
completedImagePaths.removeAll()
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
class func deleteFile(atPath filePath: String) {
|
|
50
|
+
let fileManager = FileManager.default
|
|
51
|
+
var _filePath = filePath
|
|
52
|
+
if _filePath.hasPrefix("file://") {
|
|
53
|
+
_filePath = _filePath.replacingOccurrences(of: "file://", with: "")
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if fileManager.fileExists(atPath: _filePath) {
|
|
57
|
+
do {
|
|
58
|
+
try fileManager.removeItem(atPath: _filePath)
|
|
59
|
+
print("File deleted successfully: \(_filePath)")
|
|
60
|
+
} catch {
|
|
61
|
+
print("Error deleting file: \(error.localizedDescription)")
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
print("File not found at path: \(_filePath)")
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
48
68
|
}
|
package/ios/Utils/Uploader.swift
CHANGED
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
import Foundation
|
|
9
|
+
import MobileCoreServices
|
|
10
|
+
|
|
11
|
+
enum UploaderUploadType: Int {
|
|
12
|
+
case UploaderInvalidType = -1
|
|
13
|
+
case UploaderBinaryContent = 0
|
|
14
|
+
case UploaderMultipart = 1
|
|
15
|
+
}
|
|
9
16
|
|
|
10
17
|
struct UploadError: Error {
|
|
11
18
|
private let message: String
|
|
@@ -44,11 +51,19 @@ class Uploader : NSObject, URLSessionTaskDelegate{
|
|
|
44
51
|
return
|
|
45
52
|
}
|
|
46
53
|
|
|
47
|
-
guard let
|
|
54
|
+
guard let localFile = URL(string: fileUrl) else{
|
|
48
55
|
let uploadError = UploadError(message: "invalid file url")
|
|
49
56
|
reject("Failed", "Upload Failed", uploadError)
|
|
50
57
|
return
|
|
51
58
|
}
|
|
59
|
+
|
|
60
|
+
let fieldName = options["fieldName"] as? String ?? "file"
|
|
61
|
+
let mimeType = options["mimeType"] as? String ?? ""
|
|
62
|
+
|
|
63
|
+
let parameters = options["parameters"] as? [String: String]
|
|
64
|
+
|
|
65
|
+
let uploadType = options["uploadType"] as? Int ?? 0
|
|
66
|
+
|
|
52
67
|
|
|
53
68
|
let headers = options["headers"] as? [String: String] ?? [:]
|
|
54
69
|
|
|
@@ -61,11 +76,30 @@ class Uploader : NSObject, URLSessionTaskDelegate{
|
|
|
61
76
|
|
|
62
77
|
uploadResolvers[uuid] = resolve
|
|
63
78
|
uploadRejectors[uuid] = reject
|
|
64
|
-
|
|
79
|
+
|
|
80
|
+
let type:UploaderUploadType=self.getUploadType(from: uploadType)
|
|
81
|
+
|
|
65
82
|
let config = URLSessionConfiguration.background(withIdentifier: uuid)
|
|
66
83
|
let session = URLSession(configuration: config, delegate: self, delegateQueue: nil)
|
|
67
|
-
|
|
68
|
-
|
|
84
|
+
var task:URLSessionUploadTask!;
|
|
85
|
+
if type == .UploaderBinaryContent {
|
|
86
|
+
task = session.uploadTask(with: request, fromFile: localFile)
|
|
87
|
+
} else if type == .UploaderMultipart {
|
|
88
|
+
let boundaryString = UUID().uuidString
|
|
89
|
+
let data = try? createMultipartBody(boundary: boundaryString, sourceUrl:localFile,parameters:parameters,fieldName:fieldName,mimeType:mimeType)
|
|
90
|
+
|
|
91
|
+
request.setValue("multipart/form-data; boundary=\(boundaryString)", forHTTPHeaderField: "Content-Type")
|
|
92
|
+
request.httpBody = data
|
|
93
|
+
|
|
94
|
+
task=session.uploadTask(withStreamedRequest: request)
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
let errorMessage = String(format: "Invalid upload type: '%@'.", options["uploadType"] as? String ?? "")
|
|
98
|
+
reject("ERR_FILESYSTEM_INVALID_UPLOAD_TYPE", errorMessage, nil)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
task.resume()
|
|
102
|
+
|
|
69
103
|
}
|
|
70
104
|
|
|
71
105
|
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
|
|
@@ -96,4 +130,89 @@ class Uploader : NSObject, URLSessionTaskDelegate{
|
|
|
96
130
|
guard let uuid = session.configuration.identifier else {return}
|
|
97
131
|
EventEmitterHandler.emituploadProgress(uuid,totalBytesSent: totalBytesSent,totalBytesExpectedToSend: totalBytesExpectedToSend)
|
|
98
132
|
}
|
|
133
|
+
|
|
134
|
+
func headersForMultipartParams(_ params: [String: String]?, boundary: String) -> String {
|
|
135
|
+
guard let params else {
|
|
136
|
+
return ""
|
|
137
|
+
}
|
|
138
|
+
return params.map { (key: String, value: String) in
|
|
139
|
+
"""
|
|
140
|
+
--\(boundary)
|
|
141
|
+
Content-Disposition: form-data; name="\(key)"
|
|
142
|
+
|
|
143
|
+
\(value)
|
|
144
|
+
"""
|
|
145
|
+
}
|
|
146
|
+
.joined()
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
func createMultipartBody(boundary: String, sourceUrl: URL, parameters: [String: String]? = nil, fieldName: String? = nil, mimeType: String? = nil) throws -> Data {
|
|
150
|
+
var body = Data()
|
|
151
|
+
|
|
152
|
+
// Add boundary
|
|
153
|
+
let boundaryPrefix = "--\(boundary)\r\n"
|
|
154
|
+
body.append(boundaryPrefix.data(using: .utf8)!)
|
|
155
|
+
|
|
156
|
+
// Add content disposition for the file
|
|
157
|
+
var contentDisposition = "Content-Disposition: form-data; name=\"file\"; filename=\"\(sourceUrl.lastPathComponent)\"\r\n"
|
|
158
|
+
if let fieldName = fieldName {
|
|
159
|
+
contentDisposition = "Content-Disposition: form-data; name=\"\(fieldName)\"; filename=\"\(sourceUrl.lastPathComponent)\"\r\n"
|
|
160
|
+
}
|
|
161
|
+
body.append(contentDisposition.data(using: .utf8)!)
|
|
162
|
+
|
|
163
|
+
// Add optional MIME type
|
|
164
|
+
if let mimeType = mimeType {
|
|
165
|
+
let contentType = "Content-Type: \(mimeType)\r\n"
|
|
166
|
+
body.append(contentType.data(using: .utf8)!)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Add blank line
|
|
170
|
+
body.append("\r\n".data(using: .utf8)!)
|
|
171
|
+
|
|
172
|
+
// Add file data
|
|
173
|
+
let fileData = try Data(contentsOf: sourceUrl)
|
|
174
|
+
body.append(fileData)
|
|
175
|
+
|
|
176
|
+
// Add parameters, if any
|
|
177
|
+
if let parameters = parameters {
|
|
178
|
+
for (key, value) in parameters {
|
|
179
|
+
body.append("\r\n".data(using: .utf8)!)
|
|
180
|
+
body.append(boundaryPrefix.data(using: .utf8)!)
|
|
181
|
+
let parameterContentDisposition = "Content-Disposition: form-data; name=\"\(key)\"\r\n\r\n"
|
|
182
|
+
body.append(parameterContentDisposition.data(using: .utf8)!)
|
|
183
|
+
body.append(value.data(using: .utf8)!)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Add closing boundary
|
|
188
|
+
let closingBoundary = "\r\n--\(boundary)--\r\n"
|
|
189
|
+
body.append(closingBoundary.data(using: .utf8)!)
|
|
190
|
+
|
|
191
|
+
return body
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
func findMimeType(forAttachment attachment: URL) -> String {
|
|
195
|
+
if let identifier = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, attachment.pathExtension as CFString, nil)?.takeRetainedValue() {
|
|
196
|
+
if let type = UTTypeCopyPreferredTagWithClass(identifier, kUTTagClassMIMEType)?.takeRetainedValue() {
|
|
197
|
+
return type as String
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return "application/octet-stream"
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
func getUploadType(from type: Int?) -> UploaderUploadType {
|
|
204
|
+
guard let typeValue = type else {
|
|
205
|
+
return .UploaderInvalidType
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
switch typeValue {
|
|
209
|
+
case UploaderUploadType.UploaderBinaryContent.rawValue,
|
|
210
|
+
UploaderUploadType.UploaderMultipart.rawValue:
|
|
211
|
+
return UploaderUploadType(rawValue: typeValue) ?? .UploaderInvalidType
|
|
212
|
+
default:
|
|
213
|
+
return .UploaderInvalidType
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
|
|
99
218
|
}
|
package/ios/Utils/Utils.swift
CHANGED
|
@@ -107,4 +107,24 @@ class Utils {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
static func getfileSizeInBytes(forURL url: Any) -> Double {
|
|
111
|
+
var fileURL: URL?
|
|
112
|
+
var fileSize: Double = 0.0
|
|
113
|
+
if (url is URL) || (url is String)
|
|
114
|
+
{
|
|
115
|
+
if (url is URL) {
|
|
116
|
+
fileURL = url as? URL
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
fileURL = URL(fileURLWithPath: url as! String)
|
|
120
|
+
}
|
|
121
|
+
var fileSizeValue = 0.0
|
|
122
|
+
try? fileSizeValue = (fileURL?.resourceValues(forKeys: [URLResourceKey.fileSizeKey]).allValues.first?.value as! Double?)!
|
|
123
|
+
if fileSizeValue > 0.0 {
|
|
124
|
+
fileSize = Double(fileSizeValue)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return fileSize
|
|
128
|
+
}
|
|
129
|
+
|
|
110
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_Main","require","_utils","_reactNative","base64UrlRegex","ImageCompressEventEmitter","NativeEventEmitter","Compressor","NativeImage","Image","compress","value","options","arguments","length","undefined","Error","subscription","downloadProgress","uuid","uuidv4","addListener","event","data","progress","cleanData","replace","image_compress","remove","_default","exports","default"],"sourceRoot":"../../../src","sources":["Image/index.tsx"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAGA,IAAAE,YAAA,GAAAF,OAAA;AAFA,MAAMG,cAAc,GAAG,6CAA6C;
|
|
1
|
+
{"version":3,"names":["_Main","require","_utils","_reactNative","base64UrlRegex","ImageCompressEventEmitter","NativeEventEmitter","Compressor","NativeImage","Image","compress","value","options","arguments","length","undefined","Error","subscription","downloadProgress","uuid","uuidv4","addListener","event","data","progress","cleanData","replace","image_compress","remove","_default","exports","default"],"sourceRoot":"../../../src","sources":["Image/index.tsx"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAGA,IAAAE,YAAA,GAAAF,OAAA;AAFA,MAAMG,cAAc,GAAG,6CAA6C;AAuDpE,MAAMC,yBAAyB,GAAG,IAAIC,+BAAkB,CAACC,gBAAU,CAAC;AAEpE,MAAMC,WAAW,GAAGD,gBAAU;AAM9B,MAAME,KAAgB,GAAG;EACvBC,QAAQ,EAAE,eAAAA,CAAOC,KAAK,EAAmB;IAAA,IAAjBC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAClC,IAAI,CAACF,KAAK,EAAE;MACV,MAAM,IAAIK,KAAK,CACb,qEACF,CAAC;IACH;IAEA,IAAIC,YAAqC;IACzC,IAAI;MACF,IAAIL,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEM,gBAAgB,EAAE;QAC7B,MAAMC,IAAI,GAAG,IAAAC,aAAM,EAAC,CAAC;QACrB;QACAR,OAAO,CAACO,IAAI,GAAGA,IAAI;QACnBF,YAAY,GAAGZ,yBAAyB,CAACgB,WAAW,CAClD,kBAAkB,EACjBC,KAAU,IAAK;UACd,IAAIA,KAAK,CAACH,IAAI,KAAKA,IAAI,EAAE;YACvBP,OAAO,CAACM,gBAAgB,IACtBN,OAAO,CAACM,gBAAgB,CAACI,KAAK,CAACC,IAAI,CAACC,QAAQ,CAAC;UACjD;QACF,CACF,CAAC;MACH;MAEA,MAAMC,SAAS,GAAGd,KAAK,CAACe,OAAO,CAACtB,cAAc,EAAE,EAAE,CAAC;MACnD,OAAO,MAAMI,WAAW,CAACmB,cAAc,CAACF,SAAS,EAAEb,OAAO,CAAC;IAC7D,CAAC,SAAS;MACR;MACA,IAAIK,YAAY,EAAE;QAChBA,YAAY,CAACW,MAAM,CAAC,CAAC;MACvB;IACF;EACF;AACF,CAAC;AAAC,IAAAC,QAAA,GAEapB,KAAK;AAAAqB,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -15,6 +15,18 @@ Object.defineProperty(exports, "Image", {
|
|
|
15
15
|
return _Image.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "UploadType", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _utils.UploadType;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "UploaderHttpMethod", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _utils.UploaderHttpMethod;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
18
30
|
Object.defineProperty(exports, "Video", {
|
|
19
31
|
enumerable: true,
|
|
20
32
|
get: function () {
|
|
@@ -100,7 +112,9 @@ var _default = {
|
|
|
100
112
|
backgroundUpload: _utils.backgroundUpload,
|
|
101
113
|
createVideoThumbnail: _utils.createVideoThumbnail,
|
|
102
114
|
clearCache: _utils.clearCache,
|
|
103
|
-
download: _utils.download
|
|
115
|
+
download: _utils.download,
|
|
116
|
+
UploadType: _utils.UploadType,
|
|
117
|
+
UploaderHttpMethod: _utils.UploaderHttpMethod
|
|
104
118
|
};
|
|
105
119
|
exports.default = _default;
|
|
106
120
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_Video","_interopRequireDefault","require","_Audio","_Image","_utils","obj","__esModule","default","_default","Video","Audio","Image","getDetails","uuidv4","generateFilePath","getRealPath","getVideoMetaData","getFileSize","backgroundUpload","createVideoThumbnail","clearCache","download","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_Video","_interopRequireDefault","require","_Audio","_Image","_utils","obj","__esModule","default","_default","Video","Audio","Image","getDetails","uuidv4","generateFilePath","getRealPath","getVideoMetaData","getFileSize","backgroundUpload","createVideoThumbnail","clearCache","download","UploadType","UploaderHttpMethod","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAaiB,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,IAAAG,QAAA,GAqBF;EACbC,KAAK,EAALA,cAAK;EACLC,KAAK,EAALA,cAAK;EACLC,KAAK,EAALA,cAAK;EACLC,UAAU,EAAVA,iBAAU;EACVC,MAAM,EAANA,aAAM;EACNC,gBAAgB,EAAhBA,uBAAgB;EAChBC,WAAW,EAAXA,kBAAW;EACXC,gBAAgB,EAAhBA,uBAAgB;EAChBC,WAAW,EAAXA,kBAAW;EACXC,gBAAgB,EAAhBA,uBAAgB;EAChBC,oBAAoB,EAApBA,2BAAoB;EACpBC,UAAU,EAAVA,iBAAU;EACVC,QAAQ,EAARA,eAAQ;EACRC,UAAU,EAAVA,iBAAU;EACVC,kBAAkB,EAAlBA;AACF,CAAC;AAAAC,OAAA,CAAAjB,OAAA,GAAAC,QAAA"}
|
|
@@ -3,11 +3,24 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.backgroundUpload = void 0;
|
|
6
|
+
exports.backgroundUpload = exports.UploaderHttpMethod = exports.UploadType = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
var _Main = require("../Main");
|
|
9
9
|
var _ = require(".");
|
|
10
10
|
const CompressEventEmitter = new _reactNative.NativeEventEmitter(_Main.Compressor);
|
|
11
|
+
let UploadType = /*#__PURE__*/function (UploadType) {
|
|
12
|
+
UploadType[UploadType["BINARY_CONTENT"] = 0] = "BINARY_CONTENT";
|
|
13
|
+
UploadType[UploadType["MULTIPART"] = 1] = "MULTIPART";
|
|
14
|
+
return UploadType;
|
|
15
|
+
}({});
|
|
16
|
+
exports.UploadType = UploadType;
|
|
17
|
+
let UploaderHttpMethod = /*#__PURE__*/function (UploaderHttpMethod) {
|
|
18
|
+
UploaderHttpMethod["POST"] = "POST";
|
|
19
|
+
UploaderHttpMethod["PUT"] = "PUT";
|
|
20
|
+
UploaderHttpMethod["PATCH"] = "PATCH";
|
|
21
|
+
return UploaderHttpMethod;
|
|
22
|
+
}({});
|
|
23
|
+
exports.UploaderHttpMethod = UploaderHttpMethod;
|
|
11
24
|
const backgroundUpload = async (url, fileUrl, options, onProgress) => {
|
|
12
25
|
const uuid = (0, _.uuidv4)();
|
|
13
26
|
let subscription;
|
|
@@ -26,6 +39,8 @@ const backgroundUpload = async (url, fileUrl, options, onProgress) => {
|
|
|
26
39
|
uuid,
|
|
27
40
|
method: options.httpMethod,
|
|
28
41
|
headers: options.headers,
|
|
42
|
+
uploadType: options.uploadType,
|
|
43
|
+
...options,
|
|
29
44
|
url
|
|
30
45
|
});
|
|
31
46
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_Main","_","CompressEventEmitter","NativeEventEmitter","Compressor","backgroundUpload","url","fileUrl","options","onProgress","uuid","uuidv4","subscription","addListener","event","data","written","total","Platform","OS","includes","replace","result","upload","method","httpMethod","headers","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_Main","_","CompressEventEmitter","NativeEventEmitter","Compressor","UploadType","exports","UploaderHttpMethod","backgroundUpload","url","fileUrl","options","onProgress","uuid","uuidv4","subscription","addListener","event","data","written","total","Platform","OS","includes","replace","result","upload","method","httpMethod","headers","uploadType","remove"],"sourceRoot":"../../../src","sources":["utils/Uploader.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,CAAA,GAAAF,OAAA;AADA,MAAMG,oBAAoB,GAAG,IAAIC,+BAAkB,CAACC,gBAAU,CAAC;AAAC,IAEpDC,UAAU,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA;AAAAC,OAAA,CAAAD,UAAA,GAAAA,UAAA;AAAA,IAKVE,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAAAD,OAAA,CAAAC,kBAAA,GAAAA,kBAAA;AA8BvB,MAAMC,gBAAgB,GAAG,MAAAA,CAC9BC,GAAW,EACXC,OAAe,EACfC,OAAwB,EACxBC,UAAqD,KACpC;EACjB,MAAMC,IAAI,GAAG,IAAAC,QAAM,EAAC,CAAC;EACrB,IAAIC,YAAqC;EACzC,IAAI;IACF,IAAIH,UAAU,EAAE;MACdG,YAAY,GAAGb,oBAAoB,CAACc,WAAW,CAC7C,gBAAgB,EACfC,KAAU,IAAK;QACd,IAAIA,KAAK,CAACJ,IAAI,KAAKA,IAAI,EAAE;UACvBD,UAAU,CAACK,KAAK,CAACC,IAAI,CAACC,OAAO,EAAEF,KAAK,CAACC,IAAI,CAACE,KAAK,CAAC;QAClD;MACF,CACF,CAAC;IACH;IACA,IAAIC,qBAAQ,CAACC,EAAE,KAAK,SAAS,IAAIZ,OAAO,CAACa,QAAQ,CAAC,SAAS,CAAC,EAAE;MAC5Db,OAAO,GAAGA,OAAO,CAACc,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;IAC1C;IACA,MAAMC,MAAM,GAAG,MAAMrB,gBAAU,CAACsB,MAAM,CAAChB,OAAO,EAAE;MAC9CG,IAAI;MACJc,MAAM,EAAEhB,OAAO,CAACiB,UAAU;MAC1BC,OAAO,EAAElB,OAAO,CAACkB,OAAO;MACxBC,UAAU,EAAEnB,OAAO,CAACmB,UAAU;MAC9B,GAAGnB,OAAO;MACVF;IACF,CAAC,CAAC;IACF,OAAOgB,MAAM;EACf,CAAC,SAAS;IACR;IACA,IAAIV,YAAY,EAAE;MAChBA,YAAY,CAACgB,MAAM,CAAC,CAAC;IACvB;EACF;AACF,CAAC;AAACzB,OAAA,CAAAE,gBAAA,GAAAA,gBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Compressor","uuidv4","base64UrlRegex","NativeEventEmitter","ImageCompressEventEmitter","NativeImage","Image","compress","value","options","arguments","length","undefined","Error","subscription","downloadProgress","uuid","addListener","event","data","progress","cleanData","replace","image_compress","remove"],"sourceRoot":"../../../src","sources":["Image/index.tsx"],"mappings":"AAAA,SAASA,UAAU,QAAQ,SAAS;AACpC,SAASC,MAAM,QAAQ,UAAU;AACjC,MAAMC,cAAc,GAAG,6CAA6C;AAEpE,SAASC,kBAAkB,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["Compressor","uuidv4","base64UrlRegex","NativeEventEmitter","ImageCompressEventEmitter","NativeImage","Image","compress","value","options","arguments","length","undefined","Error","subscription","downloadProgress","uuid","addListener","event","data","progress","cleanData","replace","image_compress","remove"],"sourceRoot":"../../../src","sources":["Image/index.tsx"],"mappings":"AAAA,SAASA,UAAU,QAAQ,SAAS;AACpC,SAASC,MAAM,QAAQ,UAAU;AACjC,MAAMC,cAAc,GAAG,6CAA6C;AAEpE,SAASC,kBAAkB,QAAQ,cAAc;AAqDjD,MAAMC,yBAAyB,GAAG,IAAID,kBAAkB,CAACH,UAAU,CAAC;AAEpE,MAAMK,WAAW,GAAGL,UAAU;AAM9B,MAAMM,KAAgB,GAAG;EACvBC,QAAQ,EAAE,eAAAA,CAAOC,KAAK,EAAmB;IAAA,IAAjBC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAClC,IAAI,CAACF,KAAK,EAAE;MACV,MAAM,IAAIK,KAAK,CACb,qEACF,CAAC;IACH;IAEA,IAAIC,YAAqC;IACzC,IAAI;MACF,IAAIL,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAEM,gBAAgB,EAAE;QAC7B,MAAMC,IAAI,GAAGf,MAAM,CAAC,CAAC;QACrB;QACAQ,OAAO,CAACO,IAAI,GAAGA,IAAI;QACnBF,YAAY,GAAGV,yBAAyB,CAACa,WAAW,CAClD,kBAAkB,EACjBC,KAAU,IAAK;UACd,IAAIA,KAAK,CAACF,IAAI,KAAKA,IAAI,EAAE;YACvBP,OAAO,CAACM,gBAAgB,IACtBN,OAAO,CAACM,gBAAgB,CAACG,KAAK,CAACC,IAAI,CAACC,QAAQ,CAAC;UACjD;QACF,CACF,CAAC;MACH;MAEA,MAAMC,SAAS,GAAGb,KAAK,CAACc,OAAO,CAACpB,cAAc,EAAE,EAAE,CAAC;MACnD,OAAO,MAAMG,WAAW,CAACkB,cAAc,CAACF,SAAS,EAAEZ,OAAO,CAAC;IAC7D,CAAC,SAAS;MACR;MACA,IAAIK,YAAY,EAAE;QAChBA,YAAY,CAACU,MAAM,CAAC,CAAC;MACvB;IACF;EACF;AACF,CAAC;AAED,eAAelB,KAAK"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Video from './Video';
|
|
2
2
|
import Audio from './Audio';
|
|
3
3
|
import Image from './Image';
|
|
4
|
-
import { getDetails, uuidv4, generateFilePath, getRealPath, getVideoMetaData, getFileSize, backgroundUpload, createVideoThumbnail, download, clearCache } from './utils';
|
|
4
|
+
import { getDetails, uuidv4, generateFilePath, getRealPath, getVideoMetaData, getFileSize, backgroundUpload, createVideoThumbnail, download, clearCache, UploadType, UploaderHttpMethod } from './utils';
|
|
5
5
|
export { Video, Audio, Image, backgroundUpload, download,
|
|
6
6
|
//type
|
|
7
|
-
getDetails, uuidv4, generateFilePath, getRealPath, getVideoMetaData, createVideoThumbnail, clearCache, getFileSize };
|
|
7
|
+
getDetails, uuidv4, generateFilePath, getRealPath, getVideoMetaData, createVideoThumbnail, clearCache, getFileSize, UploadType, UploaderHttpMethod };
|
|
8
8
|
export default {
|
|
9
9
|
Video,
|
|
10
10
|
Audio,
|
|
@@ -18,6 +18,8 @@ export default {
|
|
|
18
18
|
backgroundUpload,
|
|
19
19
|
createVideoThumbnail,
|
|
20
20
|
clearCache,
|
|
21
|
-
download
|
|
21
|
+
download,
|
|
22
|
+
UploadType,
|
|
23
|
+
UploaderHttpMethod
|
|
22
24
|
};
|
|
23
25
|
//# sourceMappingURL=index.js.map
|