将上传文件进度显示到dropbox

时间:2016-08-06 11:11:59

标签: java swing file-upload dropbox-api event-dispatch-thread

我需要在窗口(JFrame)上显示当前正在上传到Dropbox的文件的上传进度。

我查看了多个示例,其中大多数都使用了dropbox API v1。

我需要使用API​​ v2显示上传文件到Dropbox的进度。

我用于上传文件的编码如下所示: (我如何操纵它来显示文件上传进度。)

try
        {
            File file = new File("C:\\... Storage location of file on local system");
            //reads file as input for the method to dropbox
            InputStream fileupload = new FileInputStream(file);
            //path in dropbox account to store the file 
            // if want to store it in root just put '/'
            //if want to store file in a folder '/foldername/'
            client.files().uploadBuilder("/" + file.getName())
                    .withMode(WriteMode.OVERWRITE)//always overwrites the existing file in the dropbox folder
                    .uploadAndFinish(fileupload);
            JOptionPane.showMessageDialog(null, "File uploaded to dropbox");
        }
        //exception handled
        catch (DbxException e)
        {
            //error message for uploading file to dropboxcloud
            JOptionPane.showMessageDialog(null, "Unable to upload file to Cloud \n Error: " + e);
        }
        catch (IOException e)
        {
            JOptionPane.showMessageDialog(null, "Unable to upload file to cloud \n Error: " + e);
        }

在文件上传时,有人可以帮我解决这个进展吗?

1 个答案:

答案 0 :(得分:0)