@capgo/capacitor-uploader 0.0.7 → 0.0.9
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.
|
@@ -10,7 +10,7 @@ import net.gotev.uploadservice.UploadServiceConfig;
|
|
|
10
10
|
import net.gotev.uploadservice.data.UploadNotificationConfig;
|
|
11
11
|
import net.gotev.uploadservice.data.UploadNotificationStatusConfig;
|
|
12
12
|
import net.gotev.uploadservice.observer.request.RequestObserverDelegate;
|
|
13
|
-
import net.gotev.uploadservice.protocols.
|
|
13
|
+
import net.gotev.uploadservice.protocols.binary.BinaryUploadRequest;
|
|
14
14
|
|
|
15
15
|
public class Uploader {
|
|
16
16
|
|
|
@@ -60,15 +60,15 @@ public class Uploader {
|
|
|
60
60
|
notificationTitle
|
|
61
61
|
);
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
context,
|
|
65
|
-
serverUrl
|
|
66
|
-
)
|
|
63
|
+
BinaryUploadRequest request = new BinaryUploadRequest(context, serverUrl)
|
|
67
64
|
.setMethod(httpMethod)
|
|
68
|
-
.
|
|
65
|
+
.setFileToUpload(filePath)
|
|
69
66
|
.setNotificationConfig((ctx, uploadId) -> notificationConfig)
|
|
70
67
|
.setMaxRetries(maxRetries);
|
|
71
68
|
|
|
69
|
+
// Set the Content-Type header for the file
|
|
70
|
+
request.addHeader("Content-Type", mimeType);
|
|
71
|
+
|
|
72
72
|
// Add headers
|
|
73
73
|
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
|
74
74
|
request.addHeader(entry.getKey(), entry.getValue());
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
package ee.forgr.capacitor.uploader;
|
|
2
2
|
|
|
3
|
+
import android.app.NotificationChannel;
|
|
4
|
+
import android.app.NotificationManager;
|
|
3
5
|
import android.content.Context;
|
|
6
|
+
import android.os.Build;
|
|
4
7
|
import com.getcapacitor.JSObject;
|
|
5
8
|
import com.getcapacitor.Plugin;
|
|
6
9
|
import com.getcapacitor.PluginCall;
|
|
@@ -18,8 +21,32 @@ public class UploaderPlugin extends Plugin {
|
|
|
18
21
|
|
|
19
22
|
private Uploader implementation;
|
|
20
23
|
|
|
24
|
+
private static final String CHANNEL_ID =
|
|
25
|
+
"ee.forgr.capacitor.uploader.notification_channel_id";
|
|
26
|
+
private static final String CHANNEL_NAME = "Uploader Notifications";
|
|
27
|
+
private static final String CHANNEL_DESCRIPTION =
|
|
28
|
+
"Notifications for file uploads";
|
|
29
|
+
|
|
30
|
+
private void createNotificationChannel() {
|
|
31
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
32
|
+
NotificationManager notificationManager =
|
|
33
|
+
(NotificationManager) getContext()
|
|
34
|
+
.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
35
|
+
|
|
36
|
+
NotificationChannel channel = new NotificationChannel(
|
|
37
|
+
CHANNEL_ID,
|
|
38
|
+
CHANNEL_NAME,
|
|
39
|
+
NotificationManager.IMPORTANCE_DEFAULT
|
|
40
|
+
);
|
|
41
|
+
channel.setDescription(CHANNEL_DESCRIPTION);
|
|
42
|
+
|
|
43
|
+
notificationManager.createNotificationChannel(channel);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
21
47
|
@Override
|
|
22
48
|
public void load() {
|
|
49
|
+
createNotificationChannel();
|
|
23
50
|
implementation = new Uploader(
|
|
24
51
|
getContext(),
|
|
25
52
|
new RequestObserverDelegate() {
|
|
@@ -6,7 +6,7 @@ public class UploaderPlugin: CAPPlugin {
|
|
|
6
6
|
private let implementation = Uploader()
|
|
7
7
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
8
8
|
CAPPluginMethod(name: "startUpload", returnType: CAPPluginReturnPromise),
|
|
9
|
-
CAPPluginMethod(name: "removeUpload", returnType: CAPPluginReturnPromise)
|
|
9
|
+
CAPPluginMethod(name: "removeUpload", returnType: CAPPluginReturnPromise)
|
|
10
10
|
]
|
|
11
11
|
|
|
12
12
|
override public func load() {
|