NativeScript / NativeScript/plugins
[@nativescript/background-http] Error on uploading files
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- TypeScript
- Star
- 206
- Fork
- 123
- Merge trung bình
- 2 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 1
Mô tả
Hello, after updating to newest NativeScript version, we're experiencing issues with file upload. It worked previously with NativeScript 6.
Packages:
"@nativescript/core": "^8.2.2",
"@nativescript/angular": "^13.0.3",
"@nativescript/background-http": "^6.0.0"
Upload config:
const request: Request = {
url: this._getUrl(fileToUpload.addImageResponse),
method: "PUT",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"x-ms-blob-content-type": "image/jpeg",
"x-ms-blob-type": "BlockBlob"
},
description: "Uploading " + fileToUpload.fileName,
androidAutoClearNotification: true,
androidAutoDeleteAfterUpload: true
};
const task = this.session.uploadFile(fileToUpload.nativeFile.path, request);
task.on("progress", (e) => this._progressHandler(e as ProgressEventData, fileToUpload));
task.on("error", (e) => this._errorHandler(e as ErrorEventData, fileToUpload));
task.on("responded", this._respondedHandler);
task.on("complete", () => this._completeHandler(fileToUpload));
task.on("cancelled", this._cancelledHandler); // Android only
When executing, we're getting following error:
JS: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'NotificationConfig' of undefined
JS: TypeError: Cannot read property 'NotificationConfig' of undefined
JS: at setRequestOptions (file: src/webpack:/.../node_modules/@nativescript/background-http/index.android.js:247:0)
JS: at getBinaryRequest (file: src/webpack:/.../node_modules/@nativescript/background-http/index.android.js:221:0)
JS: at Function.create (file: src/webpack:/.../node_modules/@nativescript/background-http/index.android.js:152:0)
JS: at Session.uploadFile (file: src/webpack:/.../node_modules/@nativescript/background-http/index.android.js:139:0)
JS: at UploadService._uploadToCloud (file: src/webpack:/.../src/app/sl/services/upload/upload.service.ts:251:0)
JS: at UploadService._checkAndUploadNextFile (file: src/webpack:/.../src/app/sl/services/upload/upload.service.ts:108:0)
JS: at UploadService._checkAndPrepareNextFile (file: src/webpack:/.../src/app/sl/services/upload/upload.service.ts:97:0)
JS: at file: src/webpack:/.../src/app/sl/services/upload/upload.service.ts:184:0
JS: at _ZoneDelegate.in...
Tested on multiple Android devices with android versions from 10 to 12. Not sure if iOS has the same error. Any suggestions?
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với stack trace trong node_modules/@nativescript/background-http/index.android.js, đặc biệt là setRequestOptions ở dòng 247, sau đó kiểm tra lệnh gọi upload trong src/app/sl/services/upload/upload.service.ts quanh các dòng 97, 108 và 251. Tái hiện lỗi bằng các phiên bản package và cấu hình upload được cung cấp trên Android; hoàn tất khi đã xác định được nguyên nhân và việc upload tệp không còn gây ra lỗi NotificationConfig.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- android, typescript
- Lĩnh vực
- mobile
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 35/100