1

通过一个文件夹的元数据,我可以获取要下载到本地机器的文件的相对文件路径。当我给出这个源代码的路径时do_get(),它给了我权限被拒绝的错误。这是应该下载文件并解密它们但它不能直接下载文件的代码。

  @command
  def do_decryptFiles(self, from_path, to_path, key):
    """
    Decrypt all the files given in the folder and subfolders of from_path 

    Examples:
    Dropbox> decryptFiles '/Photos' 'E:\temp' 'a13223132323232' 
    """

    folder_metadata = self.api_client.metadata(from_path)
    print "metadata:", folder_metadata
    for s in folder_metadata['contents']:
        if(s['is_dir'] == True):
            print "directory:", s['path']
        else:
            FFPath = s['path'] 
            print FFPath
            do_get(self, from_path, to_path)
            to_file = open(os.path.abspath(to_path), "wb")
            f, metadata = self.api_client.get_file_and_metadata(self.current_path + FFPath)
            to_file.write(f.read())

当它调用时open(),命令行给我 Permission Denied 错误。任何帮助,将不胜感激。

Traceback (most recent call last):
  File "example/cli_client.py", line 397, in <module>
    main()
  File "example/cli_client.py", line 394, in main
    term.cmdloop()
  File "C:\Python27\lib\cmd.py", line 142, in cmdloop
    stop = self.onecmd(line)
  File "C:\Python27\lib\cmd.py", line 219, in onecmd
    return func(arg)
  File "example/cli_client.py", line 77, in wrapper
    return f(self, *args)
  File "example/cli_client.py", line 315, in do_decryptFiles
    to_file = open(os.path.abspath(to_path), "wb")
IOError: [Errno 13] Permission denied: 'E:\\proto'
4

1 回答 1

0

听起来是本地目录权限问题?我最近遇到了类似的问题,如果这里有一些可能的解决方案。

在我看来,这不是 Dropbox API 问题,而是本地 IO 错误。

于 2013-03-22T15:23:15.547 回答