@capgo/capacitor-uploader 0.0.24 → 0.0.27
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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Capgo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -9,17 +9,14 @@ import java.util.Map;
|
|
|
9
9
|
import net.gotev.uploadservice.UploadServiceConfig;
|
|
10
10
|
import net.gotev.uploadservice.data.UploadNotificationConfig;
|
|
11
11
|
import net.gotev.uploadservice.data.UploadNotificationStatusConfig;
|
|
12
|
-
import net.gotev.uploadservice.observer.request.RequestObserverDelegate;
|
|
13
12
|
import net.gotev.uploadservice.protocols.binary.BinaryUploadRequest;
|
|
14
13
|
|
|
15
14
|
public class Uploader {
|
|
16
15
|
|
|
17
16
|
private final Context context;
|
|
18
|
-
private final RequestObserverDelegate delegate;
|
|
19
17
|
|
|
20
|
-
public Uploader(Context context
|
|
18
|
+
public Uploader(Context context) {
|
|
21
19
|
this.context = context;
|
|
22
|
-
this.delegate = delegate;
|
|
23
20
|
initializeUploadService(context);
|
|
24
21
|
}
|
|
25
22
|
|
|
@@ -15,6 +15,7 @@ import java.util.Iterator;
|
|
|
15
15
|
import java.util.Map;
|
|
16
16
|
import net.gotev.uploadservice.data.UploadInfo;
|
|
17
17
|
import net.gotev.uploadservice.network.ServerResponse;
|
|
18
|
+
import net.gotev.uploadservice.observer.request.RequestObserver;
|
|
18
19
|
import net.gotev.uploadservice.observer.request.RequestObserverDelegate;
|
|
19
20
|
|
|
20
21
|
@CapacitorPlugin(name = "Uploader")
|
|
@@ -48,8 +49,11 @@ public class UploaderPlugin extends Plugin {
|
|
|
48
49
|
@Override
|
|
49
50
|
public void load() {
|
|
50
51
|
createNotificationChannel();
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
|
|
53
|
+
// Create a request observer for all uploads
|
|
54
|
+
RequestObserver observer = new RequestObserver(
|
|
55
|
+
getContext().getApplicationContext(),
|
|
56
|
+
getActivity(),
|
|
53
57
|
new RequestObserverDelegate() {
|
|
54
58
|
@Override
|
|
55
59
|
public void onProgress(Context context, UploadInfo uploadInfo) {
|
|
@@ -94,15 +98,20 @@ public class UploaderPlugin extends Plugin {
|
|
|
94
98
|
|
|
95
99
|
@Override
|
|
96
100
|
public void onCompleted(Context context, UploadInfo uploadInfo) {
|
|
97
|
-
|
|
101
|
+
JSObject event = new JSObject();
|
|
102
|
+
event.put("name", "finished");
|
|
103
|
+
event.put("id", uploadInfo.getUploadId());
|
|
104
|
+
notifyListeners("events", event);
|
|
98
105
|
}
|
|
99
106
|
|
|
100
107
|
@Override
|
|
101
108
|
public void onCompletedWhileNotObserving() {
|
|
102
|
-
//
|
|
109
|
+
// Handle completion while not observing if needed
|
|
103
110
|
}
|
|
104
111
|
}
|
|
105
112
|
);
|
|
113
|
+
|
|
114
|
+
implementation = new Uploader(getContext().getApplicationContext());
|
|
106
115
|
}
|
|
107
116
|
|
|
108
117
|
public static String getMimeType(String url) {
|