|
1 | 1 | import { NativeModules, NativeEventEmitter, Platform } from 'react-native'; |
2 | 2 | import { v4 as uuidv4 } from 'uuid'; |
3 | | -import Upload from 'react-native-background-upload'; |
4 | 3 |
|
5 | 4 | export declare enum FileSystemUploadType { |
6 | 5 | BINARY_CONTENT = 0, |
@@ -96,45 +95,6 @@ const Video: VideoCompressorType = { |
96 | 95 | } |
97 | 96 | }, |
98 | 97 | backgroundUpload: async (url, fileUrl, options, onProgress) => { |
99 | | - if (!NativeVideoCompressor || !NativeVideoCompressor.upload) { |
100 | | - //check if expo can upload the file |
101 | | - const scheme = fileUrl.split('://')[0]; |
102 | | - if (['file'].includes(scheme)) { |
103 | | - return Upload.startUpload({ |
104 | | - url: url, |
105 | | - path: fileUrl, |
106 | | - method: options.httpMethod || 'PUT', |
107 | | - type: 'raw', |
108 | | - }) |
109 | | - .then((uploadId) => { |
110 | | - console.log('Upload started'); |
111 | | - Upload.addListener( |
112 | | - 'progress', |
113 | | - uploadId, |
114 | | - (data: any) => |
115 | | - onProgress && onProgress(parseInt(data.progress), 100) |
116 | | - ); |
117 | | - Upload.addListener('error', uploadId, (data) => { |
118 | | - throw data.error; |
119 | | - }); |
120 | | - }) |
121 | | - .catch((err) => { |
122 | | - throw err; |
123 | | - }); |
124 | | - //fallback to use expo upload |
125 | | - // return FileSystem.uploadAsync(url, fileUrl, options); |
126 | | - } else { |
127 | | - // Use poor old fetch |
128 | | - const fileRes = await fetch(fileUrl); |
129 | | - const fileBody = await fileRes.blob(); |
130 | | - |
131 | | - return fetch(url, { |
132 | | - method: options.httpMethod, |
133 | | - body: fileBody, |
134 | | - headers: options.headers, |
135 | | - }); |
136 | | - } |
137 | | - } |
138 | 98 | const uuid = uuidv4(); |
139 | 99 | let subscription = null; |
140 | 100 | try { |
|
0 commit comments