data upload
This commit is contained in:
@@ -274,8 +274,7 @@ export class JobreviewPage implements OnInit {
|
||||
uid: string,
|
||||
contract: string,
|
||||
sessionid: string,
|
||||
msg_type:'FILE',
|
||||
file: any
|
||||
msg_type:'FILE'
|
||||
};
|
||||
|
||||
async pickFiles (fileMode) {
|
||||
@@ -295,25 +294,31 @@ export class JobreviewPage implements OnInit {
|
||||
uid: this.sessionDataProviderService.member_uid,
|
||||
contract: this.jobData.contract,
|
||||
sessionid: this.sessionDataProviderService.session ,
|
||||
msg_type:'FILE',
|
||||
file: result.files[0]
|
||||
msg_type:'FILE'
|
||||
};
|
||||
|
||||
console.log(this.uploadFormData);
|
||||
for (const [key, value] of Object.entries( this.uploadFormData )) {
|
||||
console.log(`${key}: ${value}`);
|
||||
}
|
||||
/*
|
||||
this.uploadFormData.forEach(({ name }, index) => {
|
||||
let sentence = `I am ${name} a staff of Royal Suites.`;
|
||||
console.log(sentence);
|
||||
});
|
||||
*/
|
||||
//debugger;
|
||||
//result.files[0]
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('file', this.uploadFormData.file )
|
||||
formData.append('uid', this.sessionDataProviderService.member_uid)
|
||||
formData.append('sessionid', this.sessionDataProviderService.session)
|
||||
formData.append('member_id', this.sessionDataProviderService.member_id.toString())
|
||||
formData.append('action', '14010')
|
||||
formData.append('msg_type', 'FILE')
|
||||
formData.append('contract', this.jobData.contract)
|
||||
|
||||
this.mediaConnectService.uploadtaskFile(formData).subscribe(
|
||||
|
||||
var blob = new Blob([ result.files[0].data ], { type: result.files[0].mimeType });
|
||||
var file = new File([blob], result.files[0].name, {type: result.files[0].mimeType });
|
||||
//return;
|
||||
this.mediaConnectService.uploadtaskFile(this.uploadFormData, file).subscribe(
|
||||
uploadResult => {
|
||||
this.uploadResult = uploadResult;
|
||||
console.log("this.mediaConnectService.uploadFile RETURN DATA->", formData);
|
||||
console.log("this.mediaConnectService.uploadFile RETURN DATA->", this.uploadFormData);
|
||||
const event = new Event("app-taskactivities-refresh");
|
||||
// Dispatch the event.
|
||||
dispatchEvent(event);
|
||||
|
||||
@@ -22,7 +22,15 @@ export class MediaConnectService {
|
||||
this.url = 'https://dev-media.wrenchboard.com';
|
||||
}
|
||||
|
||||
sendPostData(reqPath:string, reqData): Observable<any> {
|
||||
sendPostData(reqPath:string, reqData, file:File): Observable<any> {
|
||||
|
||||
|
||||
const formData = new FormData();
|
||||
for (const [key, value] of Object.entries( reqData )) {
|
||||
console.log(`${key}: ${value}`);
|
||||
formData.append(key, value.toString() )
|
||||
}
|
||||
formData.append("file", file );
|
||||
let headers = new HttpHeaders({
|
||||
'Content-Type': 'application/json',
|
||||
/* 'Authorization': this.basic */});
|
||||
@@ -30,27 +38,32 @@ export class MediaConnectService {
|
||||
|
||||
headers.append('Content-Type','multipart/form-data');
|
||||
|
||||
//console.log(formData);
|
||||
/*
|
||||
const apiReturn = this.http.post(
|
||||
`${environment.baseMediaUrl}/${reqPath}`,reqData, { headers: headers}
|
||||
`${environment.baseMediaUrl}/${reqPath}`,formData, { headers: headers}
|
||||
);
|
||||
*/
|
||||
const apiReturn = this.http.post(
|
||||
`${environment.baseMediaUrl}/${reqPath}`,formData,
|
||||
);
|
||||
|
||||
// const apiReturn = this.http.post(
|
||||
// `${environment.baseMediaUrl}/${reqPath}`,reqData
|
||||
// );
|
||||
|
||||
console.log(reqData);
|
||||
|
||||
/*
|
||||
axios.post('https://dev-media.wrenchboard.com/upload/contract',reqData )
|
||||
.then( res => {})
|
||||
.catch(er => console.log(er))
|
||||
|
||||
*/
|
||||
return apiReturn;
|
||||
}
|
||||
uploadtaskFile(formData){
|
||||
uploadtaskFile(formData, file:File){
|
||||
// debugger;
|
||||
console.log("formData == > ", formData);
|
||||
const pathUpload = "upload/contract";
|
||||
return this.sendPostData(pathUpload, formData);
|
||||
return this.sendPostData(pathUpload, formData, file);
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user