NativeScript / NativeScript/plugins

[@nativescript/background-http] Error on uploading files

オープン
#283 コメント 5 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
TypeScript
スター
206
フォーク
123
平均マージ
2日 1時間
マージ済み PR(30日)
1

説明

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?

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

node_modules/@nativescript/background-http/index.android.js のスタックトレースから始め、特に 247 行目の setRequestOptions を確認し、その後 src/app/sl/services/upload/upload.service.ts の 97、108、251 行目付近にある upload 呼び出しを調べます。提供されているパッケージバージョンと upload 設定を使用して Android で失敗を再現します。原因を特定し、ファイルの upload で NotificationConfig エラーが発生しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
android, typescript
領域
mobile
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。