且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Dropbox API通过Android上传文件

更新时间:2023-01-16 16:08:55

我找到了解决方案-如果有人对此感兴趣,那就是工作代码:

I found the solution - if anyone is interested here is the working code:

private DropboxAPI<AndroidAuthSession> mDBApi;//global variable

File tmpFile = new File(fullPath, "IMG_2012-03-12_10-22-09_thumb.jpg");

FileInputStream fis = new FileInputStream(tmpFile);

            try {
                DropboxAPI.Entry newEntry = mDBApi.putFileOverwrite("IMG_2012-03-12_10-22-09_thumb.jpg", fis, tmpFile.length(), null);
            } catch (DropboxUnlinkedException e) {
                Log.e("DbExampleLog", "User has unlinked.");
            } catch (DropboxException e) {
                Log.e("DbExampleLog", "Something went wrong while uploading.");
            }