@chat21/chat21-ionic 3.4.30-rc1 → 3.4.30-rc2
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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -41,5 +41,6 @@ export abstract class UploadService {
|
|
|
41
41
|
abstract uploadProfile(userId: string, upload: UploadModel): Promise<any>;
|
|
42
42
|
abstract delete(userId: string, path: string): Promise<any>;
|
|
43
43
|
abstract deleteFile(userId: string, path: string): Promise<any>;
|
|
44
|
+
abstract deleteAsset(userId: string, path: string): Promise<any>
|
|
44
45
|
abstract deleteProfile(userId: string, path: string): Promise<any>
|
|
45
46
|
}
|
|
@@ -323,6 +323,10 @@ export class FirebaseUploadService extends UploadService {
|
|
|
323
323
|
})
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
public async deleteAsset(userId: string, path: string): Promise<any>{
|
|
327
|
+
return this.deleteProfile(userId, path);
|
|
328
|
+
}
|
|
329
|
+
|
|
326
330
|
public async deleteProfile(userId: string, path: string): Promise<any>{
|
|
327
331
|
const that = this;
|
|
328
332
|
const file_name_photo = 'photo.jpg';
|
|
@@ -51,26 +51,32 @@ export class NativeUploadService extends UploadService {
|
|
|
51
51
|
//USE IMAGE API
|
|
52
52
|
const url = this.URL_TILEDESK_UPLOAD + 'images/users'
|
|
53
53
|
return new Promise((resolve, reject) => {
|
|
54
|
-
that.http.post(url, formData, requestOptions).subscribe(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
that.http.post(url, formData, requestOptions).pipe(first()).subscribe({
|
|
55
|
+
next: (data) => {
|
|
56
|
+
const downloadURL = this.URL_TILEDESK_UPLOAD + 'images?path=' + encodeURIComponent(data?.['filename']);
|
|
57
|
+
resolve({downloadURL : downloadURL, src: downloadURL})
|
|
58
|
+
// that.BSStateUpload.next({upload: upload});
|
|
59
|
+
},
|
|
60
|
+
error: (error) => {
|
|
61
|
+
reject(error)
|
|
62
|
+
}
|
|
60
63
|
});
|
|
61
64
|
});
|
|
62
65
|
} else {
|
|
63
66
|
//USE FILE API
|
|
64
67
|
const url = this.URL_TILEDESK_UPLOAD + 'files/users'
|
|
65
68
|
return new Promise((resolve, reject) => {
|
|
66
|
-
that.http.post(url, formData, requestOptions).subscribe(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
that.http.post(url, formData, requestOptions).pipe(first()).subscribe({
|
|
70
|
+
next: (data) => {
|
|
71
|
+
const src = this.URL_TILEDESK_UPLOAD + 'files?path=' + encodeURIComponent(data['filename']);
|
|
72
|
+
const downloadURL = this.URL_TILEDESK_UPLOAD + 'files/download' + '?path=' + encodeURIComponent(data['filename']);
|
|
73
|
+
resolve({downloadURL : downloadURL, src: src})
|
|
74
|
+
// that.BSStateUpload.next({upload: upload});
|
|
75
|
+
},
|
|
76
|
+
error: (error) => {
|
|
77
|
+
this.logger.error('[NATIVE UPLOAD] - ERROR upload new file ', error)
|
|
78
|
+
reject(error)
|
|
79
|
+
}
|
|
74
80
|
});
|
|
75
81
|
});
|
|
76
82
|
}
|
|
@@ -92,8 +98,9 @@ export class NativeUploadService extends UploadService {
|
|
|
92
98
|
return new Promise((resolve, reject) => {
|
|
93
99
|
that.http.post(url, formData, requestOptions).pipe(first()).subscribe({
|
|
94
100
|
next: (data) => {
|
|
95
|
-
const
|
|
96
|
-
|
|
101
|
+
const src = this.URL_TILEDESK_UPLOAD + 'files?path=' + encodeURIComponent(data['filename']);
|
|
102
|
+
const downloadURL = this.URL_TILEDESK_UPLOAD + 'files/download?path=' + encodeURIComponent(data['filename']);
|
|
103
|
+
resolve({downloadURL : downloadURL, src: src})
|
|
97
104
|
},
|
|
98
105
|
error: (error) => {
|
|
99
106
|
reject(error)
|
|
@@ -112,19 +119,14 @@ export class NativeUploadService extends UploadService {
|
|
|
112
119
|
formData.append('file', upload.file);
|
|
113
120
|
|
|
114
121
|
const that = this;
|
|
115
|
-
const
|
|
122
|
+
const queryString = expiration !== undefined ? `?expiration=${encodeURIComponent(String(expiration))}` : ''
|
|
123
|
+
const url = this.URL_TILEDESK_FILE + `/assets${queryString}`
|
|
116
124
|
return new Promise((resolve, reject) => {
|
|
117
125
|
that.http.post(url, formData, requestOptions).pipe(first()).subscribe({
|
|
118
126
|
next: (data) => {
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
const downloadURL = directUrl || (filenameOrPath ? (this.getBaseUrl() + 'files' + '?path=' + encodeURIComponent(filenameOrPath)) : null);
|
|
123
|
-
if (!downloadURL) {
|
|
124
|
-
reject(new Error('[NATIVE UPLOAD] uploadAsset: unexpected response payload'))
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
resolve({ downloadURL: downloadURL, src: downloadURL })
|
|
127
|
+
const src = this.URL_TILEDESK_UPLOAD + 'files?path=' + data['filename'];
|
|
128
|
+
const downloadURL = this.URL_TILEDESK_UPLOAD + 'files/download?path=' + encodeURIComponent(data['filename']);
|
|
129
|
+
resolve({downloadURL : downloadURL, src: src})
|
|
128
130
|
},
|
|
129
131
|
error: (error) => {
|
|
130
132
|
reject(error)
|
|
@@ -145,8 +147,8 @@ export class NativeUploadService extends UploadService {
|
|
|
145
147
|
|
|
146
148
|
// USE IMAGE API
|
|
147
149
|
const that = this;
|
|
148
|
-
const
|
|
149
|
-
const url = this.URL_TILEDESK_FILE + `/users/photo
|
|
150
|
+
const queryString = userId?.startsWith('bot_') ? `?bot_id=${encodeURIComponent(userId.substring('bot_'.length))}` : ''
|
|
151
|
+
const url = this.URL_TILEDESK_FILE + `/users/photo${queryString}`
|
|
150
152
|
return new Promise((resolve, reject) => {
|
|
151
153
|
that.http.put(url, formData, requestOptions).pipe(first()).subscribe({
|
|
152
154
|
next: (data) => {
|
|
@@ -173,12 +175,15 @@ export class NativeUploadService extends UploadService {
|
|
|
173
175
|
const that = this;
|
|
174
176
|
const url = this.URL_TILEDESK_UPLOAD + 'images/users' + '?path=' + path.split('path=')[1]
|
|
175
177
|
return new Promise((resolve, reject) => {
|
|
176
|
-
that.http.delete(url, requestOptions).subscribe(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
that.http.delete(url, requestOptions).pipe(first()).subscribe({
|
|
179
|
+
next: (data) => {
|
|
180
|
+
// const downloadURL = this.URL_TILEDESK_IMAGES + '?path=' + data['filename'];
|
|
181
|
+
resolve(true)
|
|
182
|
+
// that.BSStateUpload.next({upload: upload});
|
|
183
|
+
},
|
|
184
|
+
error: (error) => {
|
|
185
|
+
reject(error)
|
|
186
|
+
}
|
|
182
187
|
});
|
|
183
188
|
});
|
|
184
189
|
}
|
|
@@ -208,6 +213,10 @@ export class NativeUploadService extends UploadService {
|
|
|
208
213
|
});
|
|
209
214
|
}
|
|
210
215
|
|
|
216
|
+
deleteAsset(userId: string, path: string): Promise<any>{
|
|
217
|
+
return this.deleteFile(userId, path);
|
|
218
|
+
}
|
|
219
|
+
|
|
211
220
|
deleteProfile(userId: string, path: string): Promise<any>{
|
|
212
221
|
this.logger.log('[NATIVE UPLOAD] - delete image ... upload', userId)
|
|
213
222
|
const headers = new HttpHeaders({
|