简体   繁体   English

尝试在GAE中使用Dropbox Java API下载文件

[英]Trying to download a file using Dropbox Java API in the GAE

I have an XML file on Dropbox that I want to access from my Google App Engine using the Dropbox Java API. 我在Dropbox上有一个XML文件,希望使用Dropbox Java API从Google App Engine访问该文件。 After a bit of playing around I find the GAE doesn't support FileOutputStream . 经过一番摸索,我发现GAE不支持FileOutputStream

FileOutputStream outputStream = new FileOutputStream("myFile.txt");
try {
    DbxEntry.File downloadedFile = client.getFile("/myFile.txt", null,
        outputStream);
    System.out.println("Metadata: " + downloadedFile.toString());
} 

Any ideas how I can get the XML data into my GAE (client or server side) from Dropbox? 关于如何从Dropbox将XML数据导入GAE(客户端或服务器端)的任何想法? Thanks Tim 谢谢蒂姆

Got it! 得到它了! Thanks. 谢谢。 ByteArrayOutputStream worked. ByteArrayOutputStream工作。 So for anyone else trying to read a DropBox file in a Google App Engine environment (ie read into memory), here is what worked for me 因此,对于任何尝试在Google App Engine环境中读取DropBox文件(即读入内存)的人来说,这对我来说都是有效的

String fileName = "myfile.xml"; OutputStream out = new ByteArrayOutputStream(); 
try { 
    dbxClient.getFile("/" + fileName, null, out); 
} catch (DbxException e) { 
    e.printStackTrace(); 
} 

System.out.println("File Contente: " + out.toString());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM