这个问题是在python的基础上制定的,但核心问题一般是Drive API。
我有以下 python 代码用于上传部署批处理的多个文件:
batch = service.new_batch_http_request(callback=f_delete_file_batch_callback)
for item in files_list:
filename = item.name
file_metadata = {'title' : filename}
fo = open(filename, "w+b")
fo.write(item.file.read())
media = MediaFileUpload(...)
batch.add(service.files().insert(body=file_metadata, media_body=media))
http = credential.authorize(httplib2.Http())
batch.execute(http = http)
uploaded_files = ... # Here's the question. How do I get new files?
return render(request, 'my_template.html', {'files': uploaded_files}
问题是我不明白如何获取新上传的文件,以便将新行传递给 ajax 并在客户端呈现它们:
my_template.html:
{% for item in files.items %}
<tr>
<td>{{item.title}}</td>
<td>{{item.modifiedDate}}</td>
</tr>
{% endfor %}
javascript:
$.post(url, data, function(){
$table.append(response)
});