This commit is contained in:
Peter Maquiran
2022-03-11 10:28:15 +01:00
117 changed files with 34570 additions and 1031 deletions
+26 -1
View File
@@ -5,6 +5,8 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { environment } from 'src/environments/environment';
import { LoginUserRespose } from '../models/user.model';
import { SessionStore } from '../store/session.service';
import { File } from '@ionic-native/file/ngx';
import { Platform } from '@ionic/angular';
@Injectable({
providedIn: 'root'
@@ -14,7 +16,7 @@ export class AttachmentsService {
loggeduser: LoginUserRespose;
headers: HttpHeaders;
constructor(private http: HttpClient) {
constructor(private http: HttpClient, private platform: Platform, private file: File) {
this.loggeduser = SessionStore.user
this.headers = new HttpHeaders();
@@ -61,6 +63,29 @@ export class AttachmentsService {
})
}
downloadFileAndStore(guid:any) {
var name = new Date().getTime();
const downloadPath = (
this.platform.is('android')
) ? this.file.externalDataDirectory : this.file.documentsDirectory;
let vm = this;
/** HttpClient - @angular/common/http */
this.http.get(
environment.apiURL +'objectserver/streamfiles?path='+guid,
{
responseType: 'arraybuffer',
}
).subscribe((fileBlob: Uint8Array) => {
/** File - @ionic-native/file/ngx */
vm.file.writeFile(downloadPath, "YourFileName.pdf", fileBlob, {replace: true});
console.log(downloadPath +"/"+"YourFileName.pdf")
console.log(fileBlob)
});
}
getAttachmentsBySerial(serialNumber: string): Observable<Attachment[]>{
let geturl = environment.apiURL + 'attachments/GetAttachments';