Dropbox Sync API iOS将文件复制到应用程序文档 [英] Dropbox Sync API iOS copy files to app documents

查看:80
本文介绍了Dropbox Sync API iOS将文件复制到应用程序文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dropbox Sync API允许将目录或文件从Dropbox复制到应用程序沙箱目录吗?

Does the Dropbox Sync API allow for copying directories or files from Dropbox into the app sandbox directories?

我很高兴使用Dropbox Sync API并使用Dropbox来在OS X机器和运行我的应用程序的iPad之间管理媒体资产。

I was excited to use the Dropbox Sync API and use Dropbox to manage media assets between my OS X machine and an iPad running my app.

我很快集成了Sync API,能够打开文件并将其再次保存到Dropbox中

I integrated the Sync API pretty quickly and am able to open files and save them in to Dropbox again.

由于我的应用已经设置了许多调用来动态加载媒体资产,因此尝试打开Dropbox文件系统中的所有资产会增加不必要的复杂性。我的意图是使用Sync API来确定是否有更新的资产,然后将其复制到我的应用程序目录中。

Because my app is already set up with many many calls to dynamically load media assets, it would add unnecessary complexity to try to open all those assets from the Dropbox filesystem. My intention was to use the Sync API to determine if there are updated assets and then copy them in to one of my application directories.

但似乎几乎所有对象使用Sync API返回的是DBObjects,我无法执行正常的NSFilesystem文件操作,例如复制。 DBObjects本身似乎也没有复制功能。

But it seems that nearly all the objects returned using the Sync API are DBObjects, and I can't perform normal NSFilesystem file operations such as copy. Also the DBObjects seem to have no copy functions themselves.

是否可以通过不使用CorecAPI的方式来做到这一点?

Is there any way to do this without resorting to the CorecAPI?

示例,对于名为story的任意文件类型

Example, for an arbitrary file type called story

//get a list of stories and put them in an array
    DBPath *storyPathDB = [[DBPath root] childPath:@"/storyBundlesDB"];
    NSArray *listOfStoriesDB = [[DBFilesystem sharedFilesystem] listFolder:storyPathDB error:nil];
    for (DBFileInfo *story in listOfStoriesDB)
    {
        //now I can list out the path of my stories, but that's about it...
        DBPath *storyPath = story.path;
        NSLog(@"%@",storyPath.stringValue);
        //How can I treat these stories whether they are directories or .mov, .png, and copy them to my app directory? 
    }

我在使用DropBox API和iOS进行数据同步,人们建议为此目的使用SyncAPI,但似乎没人

I saw this question here Data syncing with DropBox API and iOS where people suggested using the SyncAPI for exactly this purpose, but it seems as if noone on that thread had actually tried it.

推荐答案

您可以使用 readData 如果不能直接使用DBFile对象,则读取文件的内容,然后将其写入其他位置。

You could use readData to read the contents of the file and then write it to another location, if you can't directly use the DBFile objects.

请注意,如果要在文件(在Dropbox中)更改,则需要保持该文件打开。从本质上讲,只有在您打开文件,接收到可用更新的通知后,再调用 update

Note that if you want to get notifications when a file (in Dropbox) changes, you'll need to hold that file open. Essentially, files are only updated when you hold the file open, get a notification that there's newer content available, and then call update.

这篇关于Dropbox Sync API iOS将文件复制到应用程序文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆