简体   繁体   English

在iOS中预览保管箱文件

[英]Preview of dropbox file in iOS

I am integrating dropbox with my IOS application. 我正在将Dropbox与IOS应用程序集成。 I am able to fetch selected file meta data. 我能够获取选定的文件元数据。 But couldn't find the way to show preview after selecting the file. 但是在选择文件后找不到显示预览的方法。 Can someone suggest which API is helpful. 有人可以建议哪个API有用。

Drop box i am using is : https://www.dropbox.com/developers/dropins/chooser/ios 我正在使用的保管箱是: https : //www.dropbox.com/developers/dropins/chooser/ios

Below piece of code is called when user wants to select file from dropbox : 当用户想要从保管箱中选择文件时,将调用下面的代码:

- (void)didPressChoose
{   
    [[DBChooser defaultChooser] openChooserForLinkType:DBChooserLinkTypePreview fromViewController:self
                                            completion:^(NSArray *results)
     {   
         if ([results count]) {
             _result = results[0];
             //After getting the result, i want to preview the file
         } else {
             _result = nil;
             [[[UIAlertView alloc] initWithTitle:@"CANCELLED" message:@"user cancelled!"
                                        delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil]
              show];
         }
         [[self tableView] reloadData];
     }];
}

When you ask for DBChooserLinkTypePreview , the DBChooserResult you get back from the Chooser will have an NSURL link like this: 当您要求DBChooserLinkTypePreview ,从选择器中获得的DBChooserResult将具有如下所示的NSURL链接:

https://www.dropbox.com/s/toyzur6e0m34t7v/dropbox-logos_dropbox-glyph-blue.png https://www.dropbox.com/s/toyzur6e0m34t7v/dropbox-logos_dropbox-glyph-blue.png

This link type is meant for direct user interaction, so you can send a user there and Dropbox will display the page with a preview of the file if possible. 此链接类型用于直接用户交互,因此您可以将用户发送到那里,如果可能的话,Dropbox将显示带有文件预览的页面。

Alternatively, you may want to use DBChooserLinkTypeDirect which gives you a direct link like this: 另外,您可能想使用DBChooserLinkTypeDirect ,它为您提供了这样的直接链接:

https://dl.dropboxusercontent.com/1/view/969vkzdys770277/Testing/Images/dropbox-logos_dropbox-glyph-blue.png https://dl.dropboxusercontent.com/1/view/969vkzdys770277/Testing/Images/dropbox-logos_dropbox-glyph-blue.png

This is a direct (but temporary) link to the file contents. 这是指向文件内容的直接(但临时)链接。 You can download the file contents programmatically (eg, see How do I download and save a file locally on iOS using objective C? ) and then do whatever you want with it. 您可以以编程方式下载文件内容(例如,请参阅如何使用目标C在iOS上本地下载和保存文件? ),然后使用该文件进行任何操作。 For example, you may want to display it in an UIImageView if it's an image, etc. 例如,如果它是图像等,则可能要在UIImageView中显示它。

Also, DBChooserResult contains a thumbnails property with links to thumbnails (if the selected file was an image or video) that might be similarly useful. 此外, DBChooserResult包含一个thumbnails属性,该属性具有指向缩略图的链接(如果所选文件是图像或视频),该链接可能同样有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM