mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
merge
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user