microsoftgraph / microsoftgraph/msgraph-sdk-java

LargeFileUploadTask Upload session failed.

Ouverte
#2,332 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

status:waiting-for-triage type:bug
Langage dominant
Java
Étoiles
444
Forks
154
Merge moyen
18 h 28 min
PR mergées (30 j)
4

Description

Describe the bug

For large file uploads using com.microsoft.graph:microsoft-graph:5.80.0, it always prompts: com.microsoft.graph.core.ClientException: Upload session failed. Below is the full log

`DriveUpload DriveUpload
com.microsoft.graph.core.ClientException: Error while executing the request
at com.microsoft.graph.tasks.LargeFileUploadTask.upload(LargeFileUploadTask.java:260)
at com.geniatech.onedrive.DriveUpload.uploadFile(DriveUpload.java:119)
at com.geniatech.onedrive.DriveUpload.run(DriveUpload.java:45)
Caused by: java.util.concurrent.ExecutionException: com.microsoft.graph.core.ClientException: Upload session failed.
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:359)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1921)
at com.microsoft.graph.tasks.LargeFileUploadTask.upload(LargeFileUploadTask.java:255)
at com.geniatech.onedrive.DriveUpload.uploadFile(DriveUpload.java:119) 
at com.geniatech.onedrive.DriveUpload.run(DriveUpload.java:45) 
Caused by: com.microsoft.graph.core.ClientException: Upload session failed.
at com.microsoft.graph.tasks.LargeFileUploadRequest.upload(LargeFileUploadRequest.java:107)
at com.microsoft.graph.tasks.LargeFileUploadTask.uploadAsync(LargeFileUploadTask.java:167)
at com.microsoft.graph.tasks.LargeFileUploadTask.upload(LargeFileUploadTask.java:255) 
at com.geniatech.onedrive.DriveUpload.uploadFile(DriveUpload.java:119) 
at com.geniatech.onedrive.DriveUpload.run(DriveUpload.java:45) 
Caused by: com.microsoft.graph.core.ClientException: Error code: unauthenticated
Error message: Unauthenticated

                                                                                                PUT https://my.microsoftpersonalcontent.com/personal/2fdc61d53bdc14dc/_api/v2.0/drive/items/016254SOI4F63FDODDGFD2HROPQGFCQN4Y/uploadSession?guid=%271be67694-c6e8-490b-bb91-5928bb3e34a8%27&overwrite=True&rename=False&dc=0&tempauth=v1e.eyJzaXRlaWQiOiIxMGEzZDNiMy0wZjYxLTRjZGItOWU3OC02OTcxMTlhMjIwMzQiLCJhcHBfZGlzcGxheW5hbWUiOiJHcmFwaCIsImFwcGlkIjoiMTA3YjJiMzEtMTgyYi00NWQzLTg0MjMtODJiNDRmYThkOTdmIiwiYXVkIjoiMDAwMDAwMDMtMDAwMC0wZmYxLWNlMDAtMDAwMDAwMDAwMDAwL215Lm1pY3Jvc29mdHBlcnNvbmFsY29udGVudC5jb21AOTE4ODA0MGQtNmM2Ny00YzViLWIxMTItMzZhMzA0YjY2ZGFkIiwiZXhwIjoiMTc0MTkyNDkxMSJ9.MnNt1k9jB4BFWdYtXXI_XiAHUKX9RR5uC3afHu0CMEvvtEMOiRWVbO6lQqm_efwW2tGgZmwY4Pgjxr1OErnINH6iyZiZDitnYuJOXUncig4N43UCoTUnv76Qaq9LdccPaa4fR-4svB3ljphSJjfO-r7aBLogUfRm2qDFNhcChSbMVg1ljwMrrKCAUz50Dk8MKMCijkr5Af_9incN6Gevsg6Jg2yO_thDpE0P3rYCQd0Pom5AGbmXUel2y0dEoBNJlckCjGD7x0RZe6bVLU2-S7cJGIJmuqlL2WvopHaXGMkIx4fi8f9HW2UbBRb1OL_qcjywIrzOJxFtdiRWusWwGr_FKMkNYPCZeWLqZZDPbAcW_7C4kmDu61PQzIsDENzA0m9DXnS6zSCuBdV7wd_r8ZQfNlhPp6has8IcNH1_XC3sMKrmIlOWFsy8g4jrYm1h7xnS6-87FoMiYMhc3VwQQA.PLtp6iHBMdJ7GperLV5mVeBcj_X_x4bl7eYCXFu4R9U
                                                                                                SdkVersion : graph-java/v5.80.0
                                                                                                Content-Range : bytes 0-1652626/1652627
                                                                                                
                                                                                                
                                                                                                401 : 
                                                                                                [...]
                                                                                                
                                                                                                [Some information was truncated for brevity, enable debug logging for more details]
                                                                                                	at com.microsoft.graph.tasks.LargeFileUploadResponse.<init>(LargeFileUploadResponse.java:95)
                                                                                                	at com.microsoft.graph.tasks.LargeFileUploadResponseHandler.generateResult(LargeFileUploadResponseHandler.java:95)
                                                                                                	at com.microsoft.graph.tasks.LargeFileUploadResponseHandler.generateResult(LargeFileUploadResponseHandler.java:55)
                                                                                                	at com.microsoft.graph.http.CoreHttpProvider.processResponse(CoreHttpProvider.java:435)
                                                                                                	at com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:408)
                                                                                                	at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:225)
                                                                                                	at com.microsoft.graph.tasks.LargeFileUploadRequest.upload(LargeFileUploadRequest.java:98)
                                                                                                	... 4 more
                                                                                                Caused by: com.microsoft.graph.http.GraphServiceException: Error code: unauthenticated
                                                                                                Error message: Unauthenticated

2025-03-13 12:02:02.899 26905-27095 Netdisk com.geniatech.knote.netdisc E PUT https://my.microsoftpersonalcontent.com/personal/2fdc61d53bdc14dc/_api/v2.0/drive/items/016254SOI4F63FDODDGFD2HROPQGFCQN4Y/uploadSession?guid=%271be67694-c6e8-490b-bb91-5928bb3e34a8%27&overwrite=True&rename=False&dc=0&tempauth=v1e.eyJzaXRlaWQiOiIxMGEzZDNiMy0wZjYxLTRjZGItOWU3OC02OTcxMTlhMjIwMzQiLCJhcHBfZGlzcGxheW5hbWUiOiJHcmFwaCIsImFwcGlkIjoiMTA3YjJiMzEtMTgyYi00NWQzLTg0MjMtODJiNDRmYThkOTdmIiwiYXVkIjoiMDAwMDAwMDMtMDAwMC0wZmYxLWNlMDAtMDAwMDAwMDAwMDAwL215Lm1pY3Jvc29mdHBlcnNvbmFsY29udGVudC5jb21AOTE4ODA0MGQtNmM2Ny00YzViLWIxMTItMzZhMzA0YjY2ZGFkIiwiZXhwIjoiMTc0MTkyNDkxMSJ9.MnNt1k9jB4BFWdYtXXI_XiAHUKX9RR5uC3afHu0CMEvvtEMOiRWVbO6lQqm_efwW2tGgZmwY4Pgjxr1OErnINH6iyZiZDitnYuJOXUncig4N43UCoTUnv76Qaq9LdccPaa4fR-4svB3ljphSJjfO-r7aBLogUfRm2qDFNhcChSbMVg1ljwMrrKCAUz50Dk8MKMCijkr5Af_9incN6Gevsg6Jg2yO_thDpE0P3rYCQd0Pom5AGbmXUel2y0dEoBNJlckCjGD7x0RZe6bVLU2-S7cJGIJmuqlL2WvopHaXGMkIx4fi8f9HW2UbBRb1OL_qcjywIrzOJxFtdiRWusWwGr_FKMkNYPCZeWLqZZDPbAcW_7C4kmDu61PQzIsDENzA0m9DXnS6zSCuBdV7wd_r8ZQfNlhPp6has8IcNH1_XC3sMKrmIlOWFsy8g4jrYm1h7xnS6-87FoMiYMhc3VwQQA.PLtp6iHBMdJ7GperLV5mVeBcj_X_x4bl7eYCXFu4R9U
SdkVersion : graph-java/v5.80.0
Content-Range : bytes 0-1652626/1652627

                                                                                                401 : 
                                                                                                [...]
                                                                                                
                                                                                                [Some information was truncated for brevity, enable debug logging for more details]
                                                                                                	... 10 more`
Expected behavior

Creating files and downloading files are normal, uploading files is not clear why it is abnormal, it was still normal last year

How to reproduce

`private void uploadFile() throws Exception {
// Get an input stream for the file
File file = new File(filepath);
String itemPath = "/" + type.getFolderName() + "/" + file.getName();
LogUtils.i(TAG, "itemPath=" + itemPath + ";type=" + type);
InputStream fileStream = Files.newInputStream(file.toPath());
long streamSize = file.length();

    // Create a callback used by the upload provider
    // Called after each slice of the file is uploaded
    IProgressCallback callback = (current, max) -> {
        int progress = (int) (current * 100 / max);
        listener.onMessage(true, progress);
        LogUtils.i(TAG, "current=" + current + ";max=" + max + ";progress=" + progress);

        try {
            if (isInterrupted()) {
                LogUtils.i(TAG, "fileStream.close=");
                fileStream.close();
            }
        } catch (IOException e) {
            LogUtils.e(TAG, "uploadFile", e);
        }
    };

    DriveItemCreateUploadSessionParameterSet uploadParams = DriveItemCreateUploadSessionParameterSet.newBuilder()
            .withItem(new DriveItemUploadableProperties()).build();

    // Create an upload session
    UploadSession uploadSession = getGraphServiceClient(token)
            .me()
            .drive()
            .root()
            // itemPath like "/Folder/file.txt"
            // does not need to be a path to an existing item
            .itemWithPath(itemPath)
            .createUploadSession(uploadParams)
            .buildRequest()
            .post();

    LargeFileUploadTask<DriveItem> largeFileUploadTask = new LargeFileUploadTask<>(uploadSession, getGraphServiceClient(token), fileStream, streamSize, DriveItem.class);
    // Do the upload
    largeFileUploadTask.upload(0, null, callback);
}`
SDK Version

No response

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Reproduisez l’échec de l’exemple uploadFile(), puis suivez la requête à travers LargeFileUploadTask.upload et LargeFileUploadRequest.upload. Comparez la requête de session d’upload et sa réponse 401 avec la version du SDK indiquée dans le rapport ; le travail est considéré comme terminé lorsque les uploads de fichiers volumineux aboutissent au lieu de renvoyer "Unauthenticated".

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
java
Domaine
api
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
28/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.