0
NativeScript로 만든 모바일 앱에서 C#으로 작성한 webapi에 게시하려고합니다.NativeScript - nativescript-background-http가 작동하지 않습니다.
나는 nativescript-imagepicker
과 nativescript-background-http
을 모두 사용하고 있습니다. 그러나 error
이벤트는 항상 발생합니다. 이것은 내가 이미지의 URI를 가지고 어떻게
import * as imagepicker from "nativescript-imagepicker";
import * as bghttp from "nativescript-background-http";
: 내 두 수입 :
이
는 내가 가지고있는 코드입니다SelectImage(): void {
let context = imagepicker.create({
mode: "single"
});
context.authorize()
.then(() => { return context.present() })
.then((selection) => {
selection.forEach((selected) => {
this.signupModel.CIPath = selected.fileUri;
})
}).catch((e) => {
console.log(e);
});
}
을 내가 노력하고있어 방법이있다 데이터 게시 :
SignUp(): void {
let session = bghttp.session("image-upload");
let request = {
url: "http://localhost:53286/api/Home/Signup",
method: "POST",
headers: {
"Content-Type": "application/octet-stream",
"File-Name": this.signupModel.CIPath
},
description: "{ 'uploading': 'Uploading file...' }"
};
let task: bghttp.Task;
let params = [{
name: "ImageCI", mimeType: "image/jpeg", filename: this.signupModel.CIPath
}, {
name: "Rut", value: this.signupModel.Rut
}, {
name: "Name", value: this.signupModel.Name
}, {
name: "Address", value: this.signupModel.Address
}, {
name: "Commune", value: this.signupModel.Commune
}, {
name: "PhoneNumber", value: this.signupModel.PhoneNumber
}, {
name: "Email", value: this.signupModel.Email
}, {
name: "Password", value: this.signupModel.Password
}];
task = session.multipartUpload(params, request);
task.on("error", (response: any) => {
console.log(JSON.stringify(response));
alert({title: "Sistema 3 Esferas", message:"Error subiendo imagen...", okButtonText: "Cerrar"});
});
task.on("responded", (response: any) => {
console.log(JSON.stringify(response));
});
}
내가 뭘 잘못하고 있니? 미리 감사드립니다. :)
에뮬레이터에서 테스트 하시겠습니까? 그래서 기본 설정이'localhost'와 함께 작동하지 않는다는 것을 명심하십시오 - 자세한 내용은이 스레드를보세요 https://stackoverflow.com/a/39958955/4936697 –
무엇이 오류 응답입니까? –