Using Dropbox API to upload a file with Android

前端 未结 5 514
庸人自扰
庸人自扰 2020-12-08 15:31

How can I upload a File (graphic, audio and video file) with Android using the Dropbox API to Dropbox? I followed the tutorial on the Dropbox SDK Android page and could get

5条回答
  •  孤城傲影
    2020-12-08 16:24

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

    private DropboxAPI 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.");
                }
    

提交回复
热议问题