1
1

More than 1 year has passed since last update.

AndroidのChromeでGoogle Drive上のファイルがアップロードできない件

Last updated at Posted at 2022-11-05

JSからAndroidのChromeでGoogle Drive上のファイルをアップロードしようとすると以下のエラーが出る。

net::ERR_UPLOAD_FILE_CHANGED

ブラウザのバグだが長いこと解決されていない。
https://bugs.chromium.org/p/chromium/issues/detail?id=1063576

一度arrayBufferとしてコピーすることで避けることができる。

const buffer = await file.arrayBuffer();
const blob = new File([buffer], file.name, { type: file.type });

しかしarrayBufferのコピーが有効ではないことがあり

NG Uncaught (in promise) DOMException: The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.

のようなエラーが出ることがある。例えばsetTimeoutの中でコピーするとNGのようだ。この場合はコードの書き方を変えるしかないようだ。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1