java - 在 DropBoxAPI 本身中创建和编辑临时文件,然后保存/上传它
问题描述
我有一段代码在其中检查保管箱文件夹中的某个文件(.xlsx):
ListFolderResult result = client.files().listFolder("some path");
while (true) {
for (Metadata metadata : result.getEntries()) {
if(metadata.getName().equalsIgnoreCase(name))
{
System.out.println("Already exists file with name"+name);
return true; //file exists.
}
}
if (!result.getHasMore()) {
break;
}
result = client.files().listFolderContinue(result.getCursor());
}
return false; //file doesn't exists
这只是搜索该文件并根据它返回一个布尔值。
现在,我想要的是在保管箱本身中创建一个同名文件,而不是在我的本地系统中创建它然后上传它。我目前拥有的是:
Boolean ifExists = checkInDrop(client,userName); //client is dropbox config client and checkInDrop() is mentioned above.
if(ifExists==false)
{
try (InputStream in = new FileInputStream(userName+".xlsx"))
{
FileMetadata metadata = client.files().uploadBuilder("the same path mentioned above"+userName+".xlsx")
.uploadAndFinish(in);
}
}
如果可能的话,你们可以建议吗?如果是,那怎么办?
谢谢。
解决方案
推荐阅读
- javascript - 如何调整数据表(DT)中选定列的宽度
- python - 如何在熊猫数据框中以间隔显示`.value_counts()`
- pandas - NLP:如何使用 GoldParse 对象训练 spaCy NER 模型
- javascript - 无法使用 Jest beforeAll 返回的承诺
- scala - 如何在 scala 上初始化 AnyVal 值?
- java - Tomcat线程可以最大程度地保护Spring Boot中的对象池耗尽吗?
- javascript - JavaScript - 如何测试 WeakSet 的相等性?
- reactjs - 使用 Flask API 和 Reactjs 的多个请求
- vba - 大家好,我需要一些关于我的 VBA 代码的帮助
- javascript - Primeng 表过滤器不适用于自定义添加的字段