class FileDropboxDownloadView(LoginRequiredMixin, View):
login_url = global_login_url
def get(self, request, pk):
# return self.head(self)
# use the path to find the filename
db_query_file = self.request.path
# remove the trailing slash
db_query_file = db_query_file[:-1]
# regular expressions to remove the beginning
db_query_file = re.sub('^(/)[\w]+(/)[\w]+', '', db_query_file)
dbx = dropbox.Dropbox(dropbox_token)
return dbx.files_download(db_query_file, rev=None)
当我尝试此操作时,它只会为我提供文件的元数据,而不是文件本身。有没有办法让它返回文件?谢谢!
答案 0 :(得分:0)
# Restore the local and Dropbox files to a certain revision
def restore(rev=None):
# Restore the file on Dropbox to a certain revision
print("Restoring " + BACKUPPATH + " to revision " + rev + " on Dropbox...")
dbx.files_restore(BACKUPPATH, rev)
# Download the specific revision of the file at BACKUPPATH to LOCALFILE
print("Downloading current " + BACKUPPATH + " from Dropbox, overwriting " + LOCALFILE + "...")
dbx.files_download_to_file(LOCALFILE, BACKUPPATH, rev)