![](/img/trans.png)
[英]access dropbox files from my app, download and upload files to dropbox
[英]JPG files uploaded to Dropbox from my Android app using the Dropbox API having missing pixels
去年,我一直在使用Android应用程序将备份txt文件保存到Dropbox,没有任何问题。 今天,我还添加了将JPG文件从我的设备上传到Dropbox的代码,每张照片都缺少像素-通常是图片的下半部分-它们只是以下半部分显示为灰色。 图片的一部分似乎没有上传,但我无法解释原因。 我已经搜索过,但没有在Google或StackOverflow上找到与此问题的任何引用。...这使我感到害怕,因为到目前为止我遇到的每个问题我总是会找到其他遇到该问题并且有一个问题的人。固定。 真不敢相信我是第一个.....帮助!!!!!!
上传前的示例图片: https : //docs.google.com/file/d/0B7lHLBiiexXjc0JjbXpmMzZ2MGM/edit?usp=sharing
上传后的示例图片: https : //docs.google.com/file/d/0B7lHLBiiexXjMVhYeHdJWkZObE0/edit?usp=sharing
private class backupPhotosToDropbox extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... params) {
FileInputStream inputStream = null;
try
{
String extStorageDirectory;
extStorageDirectory = Environment.getExternalStorageDirectory().toString();
File file = new File(extStorageDirectory+ "/TAPro2/Photos");
File imageList[] = file.listFiles();
for(int i=0; i<imageList.length; i++)
{
inputStream = new FileInputStream(imageList[i]);
Entry newEntry = mDBApi.putFile("/Photos/"+ imageList[i].getName(), inputStream, file.length(),null,null);
Log.i("DbExampleLog", "The uploaded file's rev is: " + newEntry.rev);
}
}
catch (DropboxUnlinkedException e)
{
Log.e("DbExampleLog", "User has unlinked.");
}
catch (DropboxException e)
{
Log.e("DbExampleLog", "Something went wrong while uploading.");
}
catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
if (inputStream != null)
{
try
{
inputStream.close();
}
catch (IOException e) {}
}
return null;
}
}
是的-找到了问题。 而不是使用image.length,而是使用了保管箱代码中的原始folder.length。 我将file.length更改为image [i] .length,现在一切正常!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.