作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我们需要为一个文件创建一个共享链接,然后检索该链接,这样我们可以在我们的应用程序中显示它。我们能够为特定文件创建共享链接(我们可以看到它在网络上的 Box 帐户内),但我们无法检索共享链接通过 API。它始终为零,尽管 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
这就是我们创建共享链接的方式。
[photo
isShared]
返回编号。[photo shareWithPassword:@"" message:@"" emails:[NSArray
arrayWithObject:@""] callbacks:^(id<BoxOperationCallbacks>
on1){...}];
[photo isShared]
返回 YES 但 [照片sharedLink] 返回 nil如果我们在 Web 上查看,我们可以看到该文件实际上是共享的,但我们无法从 Box SDK 中检索 sharedLink。
有人遇到同样的问题吗?
最佳答案
这对我有用,基于已经发布的代码和在 github here 上找到的信息
- (void) getShareableLinkForFileId:(NSString *)fileId
{
BoxFileBlock fileSuccess = ^(BoxFile *file) {
NSDictionary *fileInfo = file.rawResponseJSON;
if (![fileInfo[@"shared_link"] isEqual:[NSNull null]]) {
NSDictionary *linkData = fileInfo[@"shared_link"];
//Do something with the link
} else {
// failure
}
};
BoxAPIJSONFailureBlock failure = ^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSDictionary *JSONDictionary) {
//Handle the failure
};
BoxFilesRequestBuilder *builder = [[BoxFilesRequestBuilder alloc] init];
BoxSharedObjectBuilder *sharedBuilder = [[BoxSharedObjectBuilder alloc] init];
sharedBuilder.access = BoxAPISharedObjectAccessOpen;
builder.sharedLink = sharedBuilder;
[[BoxSDK sharedSDK].filesManager editFileWithID:fileId requestBuilder:builder success:fileSuccess failure:failure];
}
关于iOS BoxSDK 为 sharedLink 返回 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15221081/
我们需要为一个文件创建一个共享链接,然后检索该链接,这样我们可以在我们的应用程序中显示它。我们能够为特定文件创建共享链接(我们可以看到它在网络上的 Box 帐户内),但我们无法检索共享链接通过 API
我是一名优秀的程序员,十分优秀!