gpt4 book ai didi

ios - Box api 编辑文件

转载 作者:行者123 更新时间:2023-11-29 03:32:01 25 4
gpt4 key购买 nike

我尝试使用 box-api-2 在我的 iOS 应用程序中编辑 txt 文件。

我尝试这段代码,其中 filedata - NSData with NSString,应该替换文件。

BoxFilesRequestBuilder *builder = [[BoxFilesRequestBuilder alloc] init];
builder.name = self.previewFile.name;
builder.parentID = self.folderID;
NSInputStream *inputStream = [NSInputStream inputStreamWithData:fileData];
long long contentLength = [fileData length];
[[BoxSDK sharedSDK].filesManager overwriteFileWithID:self.previewFile.modelID inputStream:inputStream contentLength:contentLength requestBuilder:builder success:^(BoxFile *file) {
NSLog(@"Yeahh");
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSDictionary *JSONDictionary) {
NSLog(@"%@", [error description]);
}];
RELEASE_SAFELY(builder);

但是我得到一个错误:

 Error Domain=com.box.sdk.errordomain Code=405 "The operation couldn’t be completed. (com.box.sdk.errordomain error 405.)" UserInfo=0x1e11b5a0 {com.box.sdk.jsonerrorresponse=<CFBasicHash 0x1e2e0460 [0x3c6e6100]>{type = immutable dict, count = 6,
entries =>
0 : <CFString 0x1e04b520 [0x3c6e6100]>{contents = "type"} = <CFString 0x1e2e5340 [0x3c6e6100]>{contents = "error"}
1 : <CFString 0x3c6cfc94 [0x3c6e6100]>{contents = "status"} = <CFNumber 0x1e289df0 [0x3c6e6100]>{value = +405, type = kCFNumberSInt64Type}
2 : <CFString 0x1e2e2ea0 [0x3c6e6100]>{contents = "code"} = <CFString 0x1e2c1620 [0x3c6e6100]>{contents = "method_not_allowed"}
3 : <CFString 0x1e28b140 [0x3c6e6100]>{contents = "help_url"} = <CFString 0x1e2defc0 [0x3c6e6100]>{contents = "http://developers.box.com/docs/#errors"}
4 : <CFString 0x1e2e2dd0 [0x3c6e6100]>{contents = "request_id"} = <CFString 0x1e2e2df0 [0x3c6e6100]>{contents = "417724859526e752ff250a"}
5 : <CFString 0x1e28b160 [0x3c6e6100]>{contents = "message"} = <CFString 0x1e2e2db0 [0x3c6e6100]>{contents = "Method Not Allowed"}
}

最佳答案

我是 Box iOS SDK 的维护者。在 builder.name(或构建器)为 nil 的情况下,我能够重现此错误。您确定已设置 self.previewFile.name 吗?

无论如何,对于覆盖,这应该无关紧要,因为 V2 API 不会对文件覆盖进行重命名(它只会更新文件的内容)。

根据 http://developers.box.com/docs/#files-upload-a-new-version-of-a-file :

The filename on Box will remain the same as the previous version. To update the file’s name, use PUT /files/{id}

我已经向 GitHub 推送了一个错误修正,它为分段上传设置了一个默认文件名(如果文件名不存在),这应该允许上传通过。 https://github.com/box/box-ios-sdk-v2/releases/tag/v1.1.2

新的 podspec 即将推出。

关于ios - Box api 编辑文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19637508/

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