Filestack视频上传

时间:2017-02-15 04:07:45

标签: javascript ios file-upload fetch

我试图将视频文件上传到filestackapi,但每次我从iPhone模拟器上的相机中我都这样做时,我最终只得到了jpg的视频而不是整个视频。

此代码不起作用:

export const uploadToFileStack = (filePath, mimetype, name) => {
  const upload = {
    uri: 'assets-library://asset/asset.mov?id=3F50F7F6-1B6A-4DF5-8CE3-EA44B58AC8C5&ext=mov',
    type: 'video/quicktime',
    name: 'default.mov',
  }
  const body = new FormData()
  body.append('fileUpload', upload)
  return fetch('https://www.filestackapi.com/api/store/S3?key=AVyls64bZTVuBwKYNAkM4z', {
    method: 'POST',
    body: body
  })
}

此代码确实有效:

export const uploadToFileStack = (filePath, mimetype, name) => {
  const upload = {
    uri: '/var/mobile/Containers/Data/Application/34A9C5C3-7B16-46E7-AF3C-CEE91071F641/Documents/C98A7D99-1FA8-43C5-80F8-F056FBCC4E5B.mov',
    type: 'video/quicktime',
    name: 'default.mov',
  }
  const body = new FormData()
  body.append('fileUpload', upload)
  return fetch('https://www.filestackapi.com/api/store/S3?key=AVyls64bRTVuBuKYNAka4z', {
    method: 'POST',
    body: body
  })

在本地工作。

0 个答案:

没有答案