Skip to content

Commit 27b9c25

Browse files
committed
AM - Error al adjuntar imagenes
1 parent 1a51711 commit 27b9c25

6 files changed

Lines changed: 93 additions & 64 deletions

File tree

package.json

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"scripts": {
99
"ng": "ng",
1010
"start": "ng serve",
11-
"version:update": "npm version \"$(ionic config get version | tr -d \\')\" --allow-same-version && config-cordova -config=config.xml set version \"$(ionic config get version | tr -d \\')\" && echo Version: $(ionic config get version)",
12-
"config:demo": "config-cordova -config=config.xml set id \"org.andesDev.mobile\" && cp google-services-demo.json platforms/android/app/google-services.json",
11+
"version:update": "npm version \"$(ionic config get version | tr -d \\')\" --allow-same-version && -config=config.xml set version \"$(ionic config get version | tr -d \\')\" && echo Version: $(ionic config get version)",
12+
"config:demo": " -config=config.xml set id \"org.andesDev.mobile\" && cp google-services-demo.json platforms/android/app/google-services.json",
1313
"prepare:demo": "cordova-res --icon-source resources/demo/icon.png --splash-source resources/demo/splash.png --icon-foreground-source resources/demo/icon.png --icon-background-source resources/demo/icon.png",
1414
"compile:demo:android": "ionic cordova build android --release",
1515
"compile:demo:ios": "ionic cordova build ios --release",
@@ -21,9 +21,9 @@
2121
"build:demo:android:aab": "npm run config:demo && npm run prepare:demo && npm run bundle:demo:android && npm run sign:demo:aab && npm run zipalign:demo:aab",
2222
"build:demo:android:apk": "npm run config:demo && npm run prepare:demo && npm run compile:demo:android && npm run sign:demo:apk && npm run zipalign:demo:apk",
2323
"build:demo:ios": "npm run config:demo && npm run prepare:demo && npm run compile:demo:ios",
24-
"config:prod": "config-cordova -config=config.xml set id \"org.andesDev.mobile\" && cp google-services-prod.json platforms/android/app/google-services.json",
24+
"config:prod": " -config=config.xml set id \"org.andesDev.mobile\" && cp google-services-prod.json platforms/android/app/google-services.json",
2525
"prepare:prod": "cordova-res",
26-
"config:ios": "config-cordova -config=config.xml set id \"ar.gob.andesDev.mobile\"",
26+
"config:ios": " -config=config.xml set id \"ar.gob.andesDev.mobile\"",
2727
"prepare:demo:ios": "ionic cordova prepare ios",
2828
"config:prod:ios": "ionic cordova prepare ios --configuration production",
2929
"compile:prod:android": "cp google-services-prod.json platforms/android/app/google-services.json && ionic cordova build android --configuration production --release",
@@ -69,29 +69,29 @@
6969
"@angular/platform-browser-dynamic": "~12.2.17",
7070
"@angular/router": "~12.2.17",
7171
"@auth0/angular-jwt": "5.0.1",
72-
"@awesome-cordova-plugins/barcode-scanner": "^6.8.0",
73-
"@awesome-cordova-plugins/call-number": "^6.8.0",
74-
"@awesome-cordova-plugins/camera": "^6.8.0",
75-
"@awesome-cordova-plugins/core": "^6.8.0",
76-
"@awesome-cordova-plugins/device": "^6.8.0",
77-
"@awesome-cordova-plugins/diagnostic": "^6.8.0",
78-
"@awesome-cordova-plugins/email-composer": "^6.8.0",
79-
"@awesome-cordova-plugins/file": "^6.8.0",
80-
"@awesome-cordova-plugins/file-chooser": "^6.8.0",
81-
"@awesome-cordova-plugins/file-opener": "^6.8.0",
82-
"@awesome-cordova-plugins/file-path": "^6.8.0",
83-
"@awesome-cordova-plugins/file-transfer": "^6.8.0",
84-
"@awesome-cordova-plugins/firebase-messaging": "^6.8.0",
85-
"@awesome-cordova-plugins/geolocation": "^6.8.0",
86-
"@awesome-cordova-plugins/google-plus": "^6.8.0",
87-
"@awesome-cordova-plugins/http": "^6.8.0",
88-
"@awesome-cordova-plugins/image-resizer": "^6.8.0",
89-
"@awesome-cordova-plugins/in-app-browser": "^6.8.0",
90-
"@awesome-cordova-plugins/network": "^6.8.0",
91-
"@awesome-cordova-plugins/photo-viewer": "^6.8.0",
92-
"@awesome-cordova-plugins/splash-screen": "^6.8.0",
93-
"@awesome-cordova-plugins/sqlite": "^6.8.0",
94-
"@awesome-cordova-plugins/status-bar": "^6.8.0",
72+
"@awesome-cordova-plugins/barcode-scanner": "^8.1.0",
73+
"@awesome-cordova-plugins/call-number": "^8.1.0",
74+
"@awesome-cordova-plugins/camera": "^8.1.0",
75+
"@awesome-cordova-plugins/core": "^8.1.0",
76+
"@awesome-cordova-plugins/device": "^8.1.0",
77+
"@awesome-cordova-plugins/diagnostic": "^8.1.0",
78+
"@awesome-cordova-plugins/email-composer": "^8.1.0",
79+
"@awesome-cordova-plugins/file": "^8.1.0",
80+
"@awesome-cordova-plugins/file-chooser": "^8.1.0",
81+
"@awesome-cordova-plugins/file-opener": "^8.1.0",
82+
"@awesome-cordova-plugins/file-path": "^8.1.0",
83+
"@awesome-cordova-plugins/file-transfer": "^8.1.0",
84+
"@awesome-cordova-plugins/firebase-messaging": "^8.1.0",
85+
"@awesome-cordova-plugins/geolocation": "^8.1.0",
86+
"@awesome-cordova-plugins/google-plus": "^8.1.0",
87+
"@awesome-cordova-plugins/http": "^8.1.0",
88+
"@awesome-cordova-plugins/image-resizer": "^8.1.0",
89+
"@awesome-cordova-plugins/in-app-browser": "^8.1.0",
90+
"@awesome-cordova-plugins/network": "^8.1.0",
91+
"@awesome-cordova-plugins/photo-viewer": "^8.1.0",
92+
"@awesome-cordova-plugins/splash-screen": "^8.1.0",
93+
"@awesome-cordova-plugins/sqlite": "^8.1.0",
94+
"@awesome-cordova-plugins/status-bar": "^8.1.0",
9595
"@google/maps": "^1.1.3",
9696
"@ionic/angular": "^5.0.0",
9797
"@ionic/storage-angular": "^3.0.6",
@@ -101,7 +101,6 @@
101101
"cordova-browser": "6.0.0",
102102
"cordova.plugins.diagnostic": "^6.0.3",
103103
"moment": "^2.29.1",
104-
"mx.ferreyra.callnumber": "0.0.2",
105104
"ng-recaptcha": "^6.1.0",
106105
"rxjs": "^6.6.3",
107106
"rxjs-compat": "^6.6.3",
@@ -128,20 +127,18 @@
128127
"@typescript-eslint/parser": "^4.28.5",
129128
"@typescript-eslint/utils": "^8.3.0",
130129
"barcodescanner-ec": "^8.1.2",
131-
"call-number": "^1.0.1",
132130
"codelyzer": "^6.0.0",
133131
"com-badrit-base64": "^0.2.0",
134-
"cordova-android": "^14.0.0",
132+
"cordova-android": "^14.0.1",
135133
"cordova-common": "^4.0.2",
136134
"cordova-ios": "^6.2.0",
137135
"cordova-plugin-advanced-http": "^3.2.2",
138136
"cordova-plugin-androidx": "^3.0.0",
139137
"cordova-plugin-androidx-adapter": "^1.1.3",
140-
"cordova-plugin-camera": "6.0.0",
138+
"cordova-plugin-camera": "^8.0.0",
141139
"cordova-plugin-device": "^2.0.2",
142140
"cordova-plugin-email-composer": "^0.9.2",
143141
"cordova-plugin-file": "^6.0.2",
144-
"cordova-plugin-file-opener": "^1.0.0",
145142
"cordova-plugin-file-opener2": "^3.0.5",
146143
"cordova-plugin-firebase-analytics": "^6.0.1",
147144
"cordova-plugin-firebase-messaging": "^6.0.0",
@@ -163,6 +160,7 @@
163160
"karma-coverage-istanbul-reporter": "~3.0.2",
164161
"karma-jasmine": "~3.3.0",
165162
"karma-jasmine-html-reporter": "^1.5.0",
163+
"mx.ferreyra.callnumber": "^0.0.2",
166164
"phonegap-plugin-multidex": "^1.0.0",
167165
"properties-parser": "^0.3.1",
168166
"protractor": "~7.0.0",
@@ -203,13 +201,13 @@
203201
"cordova-plugin-email-composer": {
204202
"ANDROID_SUPPORT_V4_VERSION": "27.+"
205203
},
206-
"mx.ferreyra.callnumber": {},
207204
"cordova-plugin-camera": {
208205
"ANDROIDX_CORE_VERSION": "1.6.+"
209206
},
210207
"barcodescanner-ec": {
211208
"ANDROID_SUPPORT_V4_VERSION": "27.+"
212209
},
210+
"mx.ferreyra.callnumber": {},
213211
"call-number": {}
214212
},
215213
"platforms": [

src/app/pages/profesional/mis-matriculas/comprobante-profesional.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { ToastProvider } from 'src/providers/toast';
88
import { DomSanitizer } from '@angular/platform-browser';
99
import { HttpClient, HttpEventType, HttpHeaders, HttpRequest } from '@angular/common/http';
1010
import { Camera, CameraOptions } from '@awesome-cordova-plugins/camera/ngx';
11+
import { File } from '@awesome-cordova-plugins/file/ngx';
1112
import * as moment from 'moment';
1213

1314
@Component({
@@ -38,7 +39,8 @@ export class ComprobanteProfesionalPage implements OnInit {
3839
private profesionalProvider: ProfesionalProvider,
3940
private camera: Camera,
4041
public authProvider: AuthProvider,
41-
public sanitizer: DomSanitizer
42+
public sanitizer: DomSanitizer,
43+
private file: File
4244
) { }
4345

4446
ngOnInit() {
@@ -58,19 +60,24 @@ export class ComprobanteProfesionalPage implements OnInit {
5860
const options: CameraOptions = {
5961
quality: 50,
6062
correctOrientation: true,
61-
destinationType: this.camera.DestinationType.DATA_URL,
63+
destinationType: this.camera.DestinationType.FILE_URI,
6264
targetWidth: 400,
6365
targetHeight: 600,
6466
encodingType: this.camera.EncodingType.JPEG,
65-
mediaType: this.camera.MediaType.PICTURE,
66-
sourceType: this.camera.PictureSourceType.CAMERA,
67-
cameraDirection: 0
67+
mediaType: this.camera.MediaType.PICTURE
6868
};
6969

70-
this.camera.getPicture(options).then(img64 => {
71-
this.documentoPreview = 'data:image/jpeg;base64,' + img64;
70+
this.camera.getPicture(options).then(async img64 => {
71+
this.documentoPreview = (window as any).Ionic.WebView.convertFileSrc(img64);
72+
73+
const base64 = await this.file.readAsDataURL(
74+
img64.substring(0, img64.lastIndexOf('/') + 1),
75+
img64.substring(img64.lastIndexOf('/') + 1)
76+
);
77+
78+
const rawBase64 = base64.split(',')[1];
7279
const contentType = 'image/jpeg';
73-
const dataBlob = this.base64toBlob(img64);
80+
const dataBlob = this.base64toBlob(rawBase64);
7481

7582
this.portFile(dataBlob, 'jpeg').subscribe(event => {
7683
if (event.type === HttpEventType.UploadProgress) {

src/app/pages/profesional/mis-matriculas/foto-profesional.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</ion-col>
2323
</ion-row>
2424

25-
<img [src]="foto" class="img-circle" id="imagen-previa" />
25+
<img [src]="fotoPreview" class="img-circle" id="imagen-previa" />
2626

2727
<ion-row>
2828
<ion-col col-6>

src/app/pages/profesional/mis-matriculas/foto-profesional.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ProfesionalProvider } from 'src/providers/profesional';
66
import { ToastProvider } from 'src/providers/toast';
77
import { Camera, CameraOptions } from '@awesome-cordova-plugins/camera/ngx';
88
import { DomSanitizer } from '@angular/platform-browser';
9+
import { File } from '@awesome-cordova-plugins/file/ngx';
910

1011
@Component({
1112
selector: 'app-foto-profesional',
@@ -20,6 +21,7 @@ export class FotoProfesionalPage implements OnInit {
2021
public profesional: any;
2122
public validado = false;
2223
public foto = null;
24+
public fotoPreview = null; // para la vista
2325
public editar = true;
2426
public extension = ['jpg', 'jpeg', 'png', 'bmp'];
2527
public files: any[] = [];
@@ -30,7 +32,8 @@ export class FotoProfesionalPage implements OnInit {
3032
private camera: Camera,
3133
private profesionalProvider: ProfesionalProvider,
3234
public authProvider: AuthProvider,
33-
public sanitizer: DomSanitizer
35+
public sanitizer: DomSanitizer,
36+
private file: File
3437
) {
3538
}
3639

@@ -50,19 +53,28 @@ export class FotoProfesionalPage implements OnInit {
5053
const options: CameraOptions = {
5154
quality: 50,
5255
correctOrientation: true,
53-
destinationType: this.camera.DestinationType.DATA_URL,
56+
destinationType: this.camera.DestinationType.FILE_URI,
5457
targetWidth: 400,
5558
targetHeight: 600,
5659
encodingType: this.camera.EncodingType.JPEG,
57-
mediaType: this.camera.MediaType.PICTURE,
58-
cameraDirection: 0
60+
mediaType: this.camera.MediaType.PICTURE
5961
};
6062

61-
this.camera.getPicture(options).then((imageData) => {
62-
this.foto = 'data:image/jpeg;base64,' + imageData;
63+
this.camera.getPicture(options).then(async (imagePath) => {
64+
65+
this.fotoPreview = (window as any).Ionic.WebView.convertFileSrc(imagePath);
66+
67+
const base64 = await this.file.readAsDataURL(
68+
imagePath.substring(0, imagePath.lastIndexOf('/') + 1),
69+
imagePath.substring(imagePath.lastIndexOf('/') + 1)
70+
);
71+
this.foto = base64;
72+
6373
this.cancelarEdicion();
64-
}, () => {
65-
this.toast.danger('El servicio momentaneamente no se encuentra disponible. Utilice la opción "Examinar"');
74+
}).catch(() => {
75+
this.toast.danger(
76+
'El servicio momentáneamente no se encuentra disponible. Utilice la opción "Examinar"'
77+
);
6678
});
6779
}
6880

src/app/pages/profesional/rup-adjuntar/rup-adjuntar.ts

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { DomSanitizer } from '@angular/platform-browser';
88
import { RupProvider } from 'src/providers/rup';
99
import { ToastProvider } from 'src/providers/toast';
1010
import { ActivatedRoute, Router } from '@angular/router';
11+
import { File } from '@awesome-cordova-plugins/file/ngx';
1112

1213
@Component({
1314
selector: 'app-rup-adjuntar',
@@ -21,6 +22,7 @@ export class RupAdjuntarPage implements OnDestroy {
2122
inProgress = false;
2223
extension = ['png', 'bmp', 'jpg', 'jpeg', 'png', 'pdf'];
2324
files: any[] = [];
25+
public fotoPreview = null; // para la vista
2426

2527
uploading = false;
2628

@@ -34,7 +36,8 @@ export class RupAdjuntarPage implements OnDestroy {
3436
private camera: Camera,
3537
private sanitizer: DomSanitizer,
3638
private router: Router,
37-
private route: ActivatedRoute
39+
private route: ActivatedRoute,
40+
private file: File
3841
) {
3942

4043
this.onResumeSubscription = platform.resume.subscribe(() => {
@@ -66,31 +69,40 @@ export class RupAdjuntarPage implements OnDestroy {
6669
const destinationType = this.platform.is('ios') ? 1 : 2;
6770
// const fileName = this.platform.is('ios') ? 'rup-adjuntos' : null;
6871
const options: CameraOptions = {
69-
// quality: 70,
7072
quality: 30,
7173
correctOrientation: true,
72-
destinationType: this.camera.DestinationType.DATA_URL,
74+
destinationType: this.camera.DestinationType.FILE_URI,
7375
targetWidth: 600,
7476
targetHeight: 600,
7577
encodingType: this.camera.EncodingType.JPEG,
7678
mediaType: this.camera.MediaType.PICTURE
7779
};
78-
this.camera.getPicture(options).then((imageData) => {
79-
item = {
80-
loading: true
81-
};
80+
81+
this.camera.getPicture(options).then(async (imagePath) => {
82+
const item: any = { loading: true };
8283
this.files.push(item);
83-
return 'data:image/jpeg;base64,' + imageData;
84-
}).then((base64File: string) => {
85-
const img: any = this.sanitizer.bypassSecurityTrustResourceUrl(base64File);
84+
85+
const webviewPath = (window as any).Ionic.WebView.convertFileSrc(imagePath);
86+
this.fotoPreview = (window as any).Ionic.WebView.convertFileSrc(imagePath);
87+
// 🔑 Convertir FILE_URI a base64
88+
const base64 = await this.file.readAsDataURL(
89+
imagePath.substring(0, imagePath.lastIndexOf('/') + 1),
90+
imagePath.substring(imagePath.lastIndexOf('/') + 1)
91+
);
92+
8693
item.ext = 'jpg';
87-
item.file = img;
88-
item.plain64 = base64File;
94+
item.file = webviewPath; // para mostrar
95+
item.plain64 = base64; // 👈 para la API
96+
item.path = imagePath;
8997
item.loading = false;
98+
9099
this.files = [...this.files];
91100
}).catch(() => {
92-
this.toast.danger('El servicio momentaneamente no se encuentra disponible. Utilice la opción "Adjuntar"');
101+
this.toast.danger(
102+
'El servicio momentáneamente no se encuentra disponible. Utilice la opción "Adjuntar"'
103+
);
93104
});
105+
94106
}
95107

96108

src/providers/auth/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ export class AuthProvider {
353353

354354
getDisclaimers(usuario: any) {
355355
if (usuario.email) {
356-
return this.network.get(`modules/gestor-usuarios/usuarios/${usuario.email}/disclaimers`);
356+
return this.network.get(`modules/gestor-usuarios/usuarios/${usuario.documento}/disclaimers`);
357357
}
358358

359359
}

0 commit comments

Comments
 (0)