1

视频上传过程开始几秒钟后,进度条停止,不显示任何错误。我注意到代码在尝试执行时冻结uploader.uploadChunk()(在几次成功尝试之后)。我之前的问题是Vimeo upload : unexpected status code (404) while resuming upload,所以在更改后我确定我有正确的upload_link

我的应用程序的代码示例如下:

        HashMap<String, String> headers = new HashMap<>();
        headers.put("Tus-Resumable", "1.0.0");
        headers.put("Authorization", getAuthHeader());
        headers.put("Accept", getAcceptHeader());
        headers.put("Content-Type", "application/offset+octet-stream");
        headers.put("Upload-Length", "" + upload.getSize());
        headers.put("Connection", "Keep-Alive");
        client.setHeaders(headers);

        TusUploader uploader = client.beginOrResumeUploadFromURL(upload, client.getUploadCreationURL());
        long totalBytes = upload.getSize();
        long uploadedBytes = uploader.getOffset();

        uploader.setChunkSize(1024);

        while (!isCancelled() && uploader.uploadChunk() > 0) {
            uploadedBytes = uploader.getOffset();
            publishProgress(uploadedBytes, totalBytes);
        }

        uploader.finish();
        return uploader.getUploadURL();

另外,这是我的应用程序的屏幕截图: 如您所见,上传进度已完成近 5 %

4

0 回答 0