无法将大多数视频文件上传到React Native中的supabase服务器

问题描述 投票:0回答:1

我遇到的问题是,某些文件,例如许多视频,似乎无法使用base64编码正确上传,但是使用React Native,supabase的更新功能仅适用于base64编码,我无法上传它们。有什么我还没有看到的解决方法吗?如有任何帮助,我们将不胜感激!

这是我的代码:

      const base64 = await FileSystem.readAsStringAsync(uri, {
        encoding: FileSystem.EncodingType.Base64,
      });

      const { error } = await supabase.storage
        .from("files")
        .upload(filePath, decode(base64), {
          contentType: mimeType,
        });

我收到的错误:“TypeError:网络请求失败”

supabase 文档:https://supabase.com/docs/reference/javascript/storage-from-upload?example=upload-file-using-arraybuffer-from-base64-file-data

Supabase documentation. Upload only possible with base64 encoding?

我尝试使用不同的编码函数,使用 blob 上传,然后直接向函数提供 DocumentPicker 返回的文件。检查是否有其他变量不正确,但其他一切都正常。图片甚至一个特定视频都已正确上传。 DocumentPicker(来自博览会):

      result = await DocumentPicker.getDocumentAsync({
        type: "*/*", // Allow all file types
        copyToCacheDirectory: true,
      });

我真的不知道如何解决这个问题。请帮忙!

javascript react-native encoding expo supabase
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.