gpt4 book ai didi

ios - 将文件上传到 firebase 时正文文件无法访问错误

转载 作者:搜寻专家 更新时间:2023-10-30 20:13:55 24 4
gpt4 key购买 nike

NSString *filetotest=[NSString stringWithFormat:@"/var/mobile/Containers/Data/Application/3A203232-06BF-41CB-8456-1F2341C06934/Documents/"];
NSString *filessss=[NSString stringWithFormat:@"/var/mobile/Containers/Data/Application/3A203232-06BF-41CB-8456-1F2341C06934/Documents/100445.jpg"];

// File located on disk
NSURL *localFile = [NSURL URLWithString:filessss];

[@"100445.jpg" writeToFile:filetotest atomically:YES];


// Get a reference to the storage service using the default Firebase App
FIRStorage *storage = [FIRStorage storage];

// Create a storage reference from our storage service
FIRStorageReference *storageRef = [storage referenceForURL:@"gs://gnts-xxxxx.appspot.com"];

// Create a reference to the file you want to upload
FIRStorageReference *riversRef = [storageRef child:@"Test"];

// Upload the file to the path "images/rivers.jpg"
FIRStorageUploadTask *uploadTask = [riversRef putFile:localFile metadata:nil completion:^(FIRStorageMetadata *metadata, NSError *error) {
if (error != nil) {
// Uh-oh, an error occurred!
} else {
// Metadata contains file metadata such as size, content-type, and download URL.
NSURL *downloadURL = metadata.downloadURL;
}
}];

出错了

CFURLResourceIsReachable 失败,因为它传递了一个没有方案的 URL

主体文件无法访问:/var/mobile/Containers/Data/Application/3A203232-06BF-41CB-8456-1F2341C06934/Documents/100445.jpg Error Domain=NSCocoaErrorDomain Code=4 “文件不存在。”

最佳答案

不,我得到的路径形式每次都更改此代码,

NSString *documentsPath= [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];

1.documentsPath/var/mobile/Containers/Data/Application/7D71C4C4-33F8-4D70-AF1E-AFDEB4634031/Documents

2。documentsPath/var/mobile/Containers/Data/Application/B47C0C4B-0FA1-4E85-9573-89F2D6389535/Documents

我静态地使用了这个文件路径,导致了这个错误。现在我的问题通过直接应用文件路径解决了,谢谢 nynohu。

关于ios - 将文件上传到 firebase 时正文文件无法访问错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41972550/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com