我试图将一个临时文件发送到Dropbox / sdcard /上的图像正在运行,但是使用此代码我得到DropboxIOException。
InputStream is = getContentResolver().openInputStream(data.getData());
Bitmap bitmap = BitmapFactory.decodeStream(is);
File outputDir = getCacheDir();
File outputFile = File.createTempFile("tmp", ".tmp", outputDir);
OutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile));
//Do something with the Image
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
FileInputStream in = new FileInputStream(outputFile);
//Upload to Dropbox with: "outputFile.getName()", "in" and "outputFile.length()"
数据来自意图,是内容URI 堆栈跟踪:
com.dropbox.client2.exception.DropboxIOException: org.apache.http.client.ClientProtocolException
at com.dropbox.client2.RESTUtility.execute(RESTUtility.java:424)
at com.dropbox.client2.DropboxAPI$BasicUploadRequest.upload(DropboxAPI.java:1280)
at test.SendAsync.doInBackground(SendAsync.java:32)
at test.SendAsync.doInBackground(SendAsync.java:17)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: org.apache.http.client.ClientProtocolException
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:557)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
at com.dropbox.client2.RESTUtility.execute(RESTUtility.java:387)
... 9 more
Caused by: org.apache.http.client.NonRepeatableRequestException: Cannot retry request with a non-repeatable request entity
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:420)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
... 12 more
SendAsync(适用于外部存储设备上的静态图像)
DropboxAPI.UploadRequest mRequest;
try {
mRequest = mDBApi.putFileRequest(outputFile.getName(), in, outputFile.length(), null, null);
mRequest.upload();
[...]