将上传文件进度显示到dropbox

问题描述 投票:0回答:1

我需要在窗口(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);
        }

当文件上传时,有人可以帮助我显示这个进度吗?

java swing file-upload dropbox-api event-dispatch-thread
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.