首页 > 解决方案 > android中的navigator.share api更改用户共享文件的名称

问题描述

我创建了一个 .csv 文件来下载它。在 Windows 中一切正常,但在 android 中,当共享文件时,它会以不同的名称下载,例如“share9457849389.csv”

const file = new File([text], 'myFile.csv', {
  type: 'text/csv'
})

if (navigator.canShare && navigator.canShare({
    files: [file]
  })) {
  navigator
    .share({
      files: [file],
      text: 'Some text',
      title: `The title`
    })
    .then(() => resolve(''))
    .catch((e: any) => reject(e))
} else reject('Bad news')

我该如何解决这个问题?

标签: javascriptgoogle-chrome-android

解决方案


推荐阅读