我遇到的问题是,某些文件,例如许多视频,似乎无法使用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:网络请求失败”
我尝试使用不同的编码函数,使用 blob 上传,然后直接向函数提供 DocumentPicker 返回的文件。检查是否有其他变量不正确,但其他一切都正常。图片甚至一个特定视频都已正确上传。 DocumentPicker(来自博览会):
result = await DocumentPicker.getDocumentAsync({
type: "*/*", // Allow all file types
copyToCacheDirectory: true,
});
我真的不知道如何解决这个问题。请帮忙!
您是否在 Supabase 文档中看到他们建议您对任何大于 5MB 的文件使用 TUS 可续传上传? (记住:base64 编码会大大增加数据的大小)