我们需要为文件创建共享链接,然后检索该链接,以便我们可以在应用程序中显示它.我们能够为特定文件创建共享链接(我们可以在Web上的Box Account中看到它)但我们无法通过API检索sharedLink.虽然isShared方法返回YES ,但它总是为零.
从头文件中BoxObject.h我们发现这两个方法提供了有关项目共享状态的必要信息.
@protocol BoxObject
// ...
// Information about the shared state of the item
@property (readonly, getter = isShared) BOOL shared;
@property (readonly) NSString *sharedLink;
//...
@end
Run Code Online (Sandbox Code Playgroud)
这就是我们创建共享链接的方式.
[photo
isShared]返回NO.[photo shareWithPassword:@"" message:@"" emails:[NSArray
arrayWithObject:@""] callbacks:^(id<BoxOperationCallbacks>
on1){...}];[photo isShared]返回YES但[photo sharedLink]返回nil如果我们检查Web,我们可以看到该文件实际上已共享,但我们无法从Box SDK中检索sharedLink.
有人有同样的问题吗?
我能够通过刷新文件夹本身来获取共享链接。这是我想出的代码:
[boxFile shareWithPassword:@"" message:@"" emails:@[ @"" ] callbacks:^(id<BoxOperationCallbacks> on) {
on.after(^(BoxCallbackResponse response) {
if (response == BoxCallbackResponseSuccessful) {
[self.rootFolder updateWithCallbacks:^(id<BoxOperationCallbacks> on) {
on.after(^(BoxCallbackResponse response) {
BoxFile *updatedBoxFile = (BoxFile*)[self.rootFolder.children objectAtIndex:self.selectedIndexPath.row];
NSString *fileName = updatedBoxFile.name;
NSString *shareLink = updatedBoxFile.sharedLink;
NSLog(@"%@ [%@]: %@", fileName, updatedBoxFile.isShared ? @"YES" : @"NO", shareLink);
});
}];
} else {
[BoxErrorHandler presentErrorAlertViewForResponse:response];
}
});
}];
Run Code Online (Sandbox Code Playgroud)
这是旧的 v1 API。不确定它是否随着较新的 v2 有所改变。
| 归档时间: |
|
| 查看次数: |
674 次 |
| 最近记录: |