René's URL Explorer Experiment


Title: ChunkedUploadProvider for AttachmentItem halts after first chunk · Issue #423 · microsoftgraph/msgraph-sdk-java · GitHub

Open Graph Title: ChunkedUploadProvider for AttachmentItem halts after first chunk · Issue #423 · microsoftgraph/msgraph-sdk-java

X Title: ChunkedUploadProvider for AttachmentItem halts after first chunk · Issue #423 · microsoftgraph/msgraph-sdk-java

Description: Uploading chunks return reponse code 200 where the ChunkedUploadResponseHandler awaits 202. That finishes the chunked upload immediately and the upload will not finish with a 201 Created. You can get it to work if you extend the ChunkedU...

Open Graph Description: Uploading chunks return reponse code 200 where the ChunkedUploadResponseHandler awaits 202. That finishes the chunked upload immediately and the upload will not finish with a 201 Created. You can g...

X Description: Uploading chunks return reponse code 200 where the ChunkedUploadResponseHandler awaits 202. That finishes the chunked upload immediately and the upload will not finish with a 201 Created. You can g...

Opengraph URL: https://github.com/microsoftgraph/msgraph-sdk-java/issues/423

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.112.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ChunkedUploadProvider for AttachmentItem halts after first chunk ","articleBody":"Uploading chunks return reponse code 200 where the ChunkedUploadResponseHandler awaits 202. That finishes the chunked upload immediately and the upload will not finish with a 201 Created.\r\nYou can get it to work if you extend the ChunkedUploadResponseHandler and overwrite the Response Code and result return:\r\npackage com.example.ms.graph;\r\n\r\n```Java\r\nimport java.io.BufferedInputStream;\r\nimport java.io.IOException;\r\nimport java.io.InputStream;\r\n\r\nimport com.microsoft.graph.concurrency.ChunkedUploadResponseHandler;\r\nimport com.microsoft.graph.http.DefaultHttpProvider;\r\nimport com.microsoft.graph.http.GraphServiceException;\r\nimport com.microsoft.graph.http.HttpResponseCode;\r\nimport com.microsoft.graph.http.IConnection;\r\nimport com.microsoft.graph.http.IHttpRequest;\r\nimport com.microsoft.graph.logger.ILogger;\r\nimport com.microsoft.graph.models.extensions.AttachmentItem;\r\nimport com.microsoft.graph.models.extensions.UploadSession;\r\nimport com.microsoft.graph.requests.extensions.ChunkedUploadResult;\r\nimport com.microsoft.graph.serializer.ISerializer;\r\n\r\nimport okhttp3.Response;\r\n\r\npublic class ChunkedUploadResponseHandler2\u003cUploadType> extends ChunkedUploadResponseHandler\u003cUploadType> {\r\n\r\n\tprivate final Class\u003cUploadType> deserializeTypeClass;\r\n\r\n\tpublic ChunkedUploadResponseHandler2(Class\u003cUploadType> deserializeTypeClass) {\r\n\t\tsuper(deserializeTypeClass);\r\n\t\tthis.deserializeTypeClass = deserializeTypeClass;\r\n\t}\r\n\r\n\t/**\r\n\t * Generate the chunked upload response result\r\n\t *\r\n\t * @param request\r\n\t *            the HTTP request\r\n\t * @param response\r\n\t *            the HTTP response\r\n\t * @param serializer\r\n\t *            the serializer\r\n\t * @param logger\r\n\t *            the system logger\r\n\t * @return the chunked upload result, which could be either an uploaded item or error\r\n\t * @throws Exception\r\n\t *             an exception occurs if the request was unable to complete for any reason\r\n\t */\r\n\t@Override\r\n\tpublic ChunkedUploadResult\u003cUploadType> generateResult(final IHttpRequest request, final Response response, final ISerializer serializer, final ILogger logger)\r\n\t\t\tthrows Exception {\r\n\t\tInputStream in = null;\r\n\t\ttry {\r\n\t\t\tif (response.code() == HttpResponseCode.HTTP_ACCEPTED || response.code() == HttpResponseCode.HTTP_OK) {\r\n\t\t\t\tlogger.logDebug(\"Chunk bytes has been accepted by the server.\");\r\n\t\t\t\tin = new BufferedInputStream(response.body().byteStream());\r\n\t\t\t\tfinal UploadSession session = serializer.deserializeObject(DefaultHttpProvider.streamToString(in), UploadSession.class);\r\n\r\n\t\t\t\treturn new ChunkedUploadResult\u003cUploadType>(session);\r\n\r\n\t\t\t}\r\n\t\t\telse if (response.code() == HttpResponseCode.HTTP_CREATED) { // || response.code() == HttpResponseCode.HTTP_OK\r\n\t\t\t\tlogger.logDebug(\"Upload session is completed, uploaded item returned.\");\r\n\t\t\t\t// in = new BufferedInputStream(response.body().byteStream());\r\n\t\t\t\t// String rawJson = DefaultHttpProvider.streamToString(in);\r\n\t\t\t\t// UploadType uploadedItem = serializer.deserializeObject(rawJson, this.deserializeTypeClass);\r\n\t\t\t\tString itemUrl = response.header(\"Location\");\r\n\t\t\t\tlogger.logDebug(String.format(\"Upload session is completed, upload url: %s\", itemUrl));\r\n\t\t\t\tAttachmentItem ai = new AttachmentItem();\r\n\t\t\t\tai.name = itemUrl;\r\n\t\t\t\tUploadType uploadedItem = (UploadType) ai;\r\n\t\t\t\treturn new ChunkedUploadResult\u003cUploadType>(uploadedItem);\r\n\t\t\t}\r\n\t\t\telse if (response.code() >= HttpResponseCode.HTTP_CLIENT_ERROR) {\r\n\t\t\t\tlogger.logDebug(\"Receiving error during upload, see detail on result error\");\r\n\r\n\t\t\t\treturn new ChunkedUploadResult\u003cUploadType>(GraphServiceException.createFromConnection(request, null, serializer, response, logger));\r\n\t\t\t}\r\n\t\t}\r\n\t\tfinally {\r\n\t\t\tif (in != null) {\r\n\t\t\t\ttry {\r\n\t\t\t\t\tin.close();\r\n\t\t\t\t}\r\n\t\t\t\tcatch (IOException e) {\r\n\t\t\t\t\tlogger.logError(e.getMessage(), e);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn null;\r\n\t}\r\n}\r\n```\r\n\r\nThis will successfully upload the file and create the resource on the server.\r\nThe call will be as stated on the documentation:\r\n```Java\r\nFile file = new File(ea.getFilepath());\r\n\r\nAttachmentItem attachmentItem = new AttachmentItem();\r\nattachmentItem.attachmentType = AttachmentType.FILE;\r\nattachmentItem.name = file.getName();\r\nattachmentItem.size = file.length();\r\nattachmentItem.contentType = \"application/octet-stream\";\r\n\r\nInputStream fileStream = new FileInputStream(file);\r\nlong streamSize = attachmentItem.size;\r\n\r\n// Create a callback used by the upload provider\r\nIProgressCallback\u003cAttachmentItem> callback = new IProgressCallback\u003c>() {\r\n    @Override\r\n    // Called after each slice of the file is uploaded\r\n    public void progress(final long current, final long max) {\r\n        logger.logDebug(String.format(\"Uploaded %d bytes of %d total bytes\", current, max));\r\n    }\r\n\r\n    @Override\r\n    public void success(final AttachmentItem result) {\r\n        logger.logDebug(String.format(\"Uploaded file.\"));\r\n    }\r\n\r\n    public void failure(final ClientException ex) {\r\n        logger.logError(String.format(\"Error uploading file: %s\", ex.getMessage()), ex);\r\n    }\r\n};\r\n\r\nUploadSession uploadSession = getClient().me().messages(drafted.id).attachments().createUploadSession(attachmentItem).buildRequest().post();\r\nlogger.logDebug(String.format(\"Upload session URL: %s\", uploadSession.uploadUrl));\r\n\r\nChunkedUploadProvider\u003cAttachmentItem> chunkedUploadProvider = new ChunkedUploadProvider\u003c>(uploadSession, getClientUnauthorized(), fileStream,\r\n        streamSize, AttachmentItem.class);\r\n\r\n// Config parameter is an array of integers\r\n// customConfig[0] indicates the max slice size\r\n// Max slice size must be a multiple of 320 KiB, numRetries\r\nint[] customConfig = {\r\n        320 * 1024, 1\r\n};\r\n\r\n// Do the upload\r\nchunkedUploadProvider.upload(callback, customConfig);\r\n```\r\n\r\nSo it needs to be checked if there is really consistent behaviour on the server side regarding the response codes for accepting chunks when using the different endpoints onedrive || messages || events etc.\r\nMaybe it is a good idea to establish separate reponsehandlers and uploadproviders for the different endpoints, especially when mixing the audience. The preauthenticated uploadurl also seems not to be the ideal solution for a permission handover.\r\nPS: Don't forget to add the permission Mail.ReadWrite in case you upload an attachment to an existing message, otherwise you will end up also in a 401!\r\nOriginally posted by @gantners in #409 (comment)\r\n[AB#6035](https://microsoftgraph.visualstudio.com/0985d294-5762-4bc2-a565-161ef349ca3e/_workitems/edit/6035)","author":{"url":"https://github.com/jball-vcra","@type":"Person","name":"jball-vcra"},"datePublished":"2020-08-18T17:51:40Z","url":"https://github.com/microsoftgraph/msgraph-sdk-java/issues/423"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:ccf5f007-75b7-90b6-54f4-8175274ff562
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC558:1F67:10908C:171700:6B0542D5
html-safe-noncea29970edd04d2515c2c81e31fd718983db08b70c708403e98915b6b03400e8fb
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNTU4OjFGNjc6MTA5MDhDOjE3MTcwMDo2QjA1NDJENSIsInZpc2l0b3JfaWQiOiI0MDYzNzc4NDU4NTkxMDc1NDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac54f11901773e9f2acb7df65e8a19c553ad37926f3f41f71cd7db013aec60124f
hovercard-subject-tagissue:681224530
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoftgraph/msgraph-sdk-java/423/issue_layout
twitter:imagehttps://opengraph.githubassets.com/76a87101ccfb14a023561e528cb14a7f2f79558a01f03df304c4be54025a1baf/microsoftgraph/msgraph-sdk-java/issues/423
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/76a87101ccfb14a023561e528cb14a7f2f79558a01f03df304c4be54025a1baf/microsoftgraph/msgraph-sdk-java/issues/423
og:image:altUploading chunks return reponse code 200 where the ChunkedUploadResponseHandler awaits 202. That finishes the chunked upload immediately and the upload will not finish with a 201 Created. You can g...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejball-vcra
hostnamegithub.com
expected-hostnamegithub.com
None854d880890b5e847b3fce9d1b31f032107baeddeebad2aa379c48aa4f1451f6b
turbo-cache-controlno-preview
go-importgithub.com/microsoftgraph/msgraph-sdk-java git https://github.com/microsoftgraph/msgraph-sdk-java.git
octolytics-dimension-user_id17304259
octolytics-dimension-user_loginmicrosoftgraph
octolytics-dimension-repository_id103300409
octolytics-dimension-repository_nwomicrosoftgraph/msgraph-sdk-java
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id103300409
octolytics-dimension-repository_network_root_nwomicrosoftgraph/msgraph-sdk-java
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release220e980097d94ce616d5d11fbd5316d208e3fc93
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoftgraph/msgraph-sdk-java/issues/423#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2Fmsgraph-sdk-java%2Fissues%2F423
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2Fmsgraph-sdk-java%2Fissues%2F423
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoftgraph%2Fmsgraph-sdk-java
Reloadhttps://github.com/microsoftgraph/msgraph-sdk-java/issues/423
Reloadhttps://github.com/microsoftgraph/msgraph-sdk-java/issues/423
Reloadhttps://github.com/microsoftgraph/msgraph-sdk-java/issues/423
microsoftgraphhttps://github.com/microsoftgraph
msgraph-sdk-javahttps://github.com/microsoftgraph/msgraph-sdk-java
Codehttps://github.com/microsoftgraph/msgraph-sdk-java
Issues107 (107)https://github.com/microsoftgraph/msgraph-sdk-java/issues
Pull requests23 (23)https://github.com/microsoftgraph/msgraph-sdk-java/pulls
Actionshttps://github.com/microsoftgraph/msgraph-sdk-java/actions
Projectshttps://github.com/microsoftgraph/msgraph-sdk-java/projects
Security and qualityhttps://github.com/microsoftgraph/msgraph-sdk-java/security
Insightshttps://github.com/microsoftgraph/msgraph-sdk-java/insights
https://github.com/microsoftgraph/msgraph-sdk-java
New issuehttps://github.com/login?return_to=https://github.com/microsoftgraph/msgraph-sdk-java/issues/423
New issuehttps://github.com/login?return_to=https://github.com/microsoftgraph/msgraph-sdk-java/issues/423
#481https://github.com/microsoftgraph/msgraph-sdk-java/pull/481
ChunkedUploadProvider for AttachmentItem halts after first chunk https://github.com/microsoftgraph/msgraph-sdk-java/issues/423#top
#481https://github.com/microsoftgraph/msgraph-sdk-java/pull/481
https://github.com/baywet
ADO to GitHub automation labelhttps://github.com/microsoftgraph/msgraph-sdk-java/issues?q=state%3Aopen%20label%3A%22ADO%20to%20GitHub%20automation%20label%22
bughttps://github.com/microsoftgraph/msgraph-sdk-java/issues?q=state%3Aopen%20label%3A%22bug%22
fixedhttps://github.com/microsoftgraph/msgraph-sdk-java/issues?q=state%3Aopen%20label%3A%22fixed%22
2.2.0https://github.com/microsoftgraph/msgraph-sdk-java/milestone/5
https://github.com/jball-vcra
jball-vcrahttps://github.com/jball-vcra
on Aug 18, 2020https://github.com/microsoftgraph/msgraph-sdk-java/issues/423#issue-681224530
Stefan Gantner (@gantners)https://github.com/gantners
AB#6035https://microsoftgraph.visualstudio.com/0985d294-5762-4bc2-a565-161ef349ca3e/_workitems/edit/6035
ToTriagehttps://github.com/microsoftgraph/msgraph-sdk-java/issues?q=state%3Aopen%20label%3A%22ToTriage%22
on Aug 18, 2020https://github.com/microsoftgraph/msgraph-sdk-java/issues/423#event-3667476118
https://github.com/gantners
Stefan Gantner (gantners)https://github.com/gantners
on Aug 18, 2020https://github.com/microsoftgraph/msgraph-sdk-java/issues/423#issuecomment-675639708
https://github.com/darrelmiller
Darrel (darrelmiller)https://github.com/darrelmiller
on Aug 18, 2020https://github.com/microsoftgraph/msgraph-sdk-java/issues/423#issuecomment-675672089
https://github.com/gantners
Stefan Gantner (gantners)https://github.com/gantners
on Aug 18, 2020https://github.com/microsoftgraph/msgraph-sdk-java/issues/423#issuecomment-675756917
Graph Documentationhttps://docs.microsoft.com/en-us/graph/outlook-large-attachments?tabs=java#response-6
https://outlook.office.com/api/beta/Users('xxxx}https://outlook.office.com/api/beta/Users('xxxx%7D
Michael Mainer (MIchaelMainer)https://github.com/MIchaelMainer
Vincent Biret (baywet)https://github.com/baywet
on Aug 20, 2020https://github.com/microsoftgraph/msgraph-sdk-java/issues/423#event-3676972359
ToTriagehttps://github.com/microsoftgraph/msgraph-sdk-java/issues?q=state%3Aopen%20label%3A%22ToTriage%22
on Aug 20, 2020https://github.com/microsoftgraph/msgraph-sdk-java/issues/423#event-3676972459
Vincent Biret (baywet)https://github.com/baywet
2.1.1https://github.com/microsoftgraph/msgraph-sdk-java/milestone/5
on Sep 4, 2020https://github.com/microsoftgraph/msgraph-sdk-java/issues/423#event-3729446216
Vincent Biret (baywet)https://github.com/baywet
ADO to GitHub automation labelhttps://github.com/microsoftgraph/msgraph-sdk-java/issues?q=state%3Aopen%20label%3A%22ADO%20to%20GitHub%20automation%20label%22
on Sep 15, 2020https://github.com/microsoftgraph/msgraph-sdk-java/issues/423#event-3769458533
https://github.com/baywet
Vincent Biret (baywet)https://github.com/baywet
on Sep 17, 2020https://github.com/microsoftgraph/msgraph-sdk-java/issues/423#issuecomment-694390124
#481https://github.com/microsoftgraph/msgraph-sdk-java/pull/481
Vincent Biret (baywet)https://github.com/baywet
bughttps://github.com/microsoftgraph/msgraph-sdk-java/issues?q=state%3Aopen%20label%3A%22bug%22
fixedhttps://github.com/microsoftgraph/msgraph-sdk-java/issues?q=state%3Aopen%20label%3A%22fixed%22
on Sep 17, 2020https://github.com/microsoftgraph/msgraph-sdk-java/issues/423#event-3779153808
Vincent Biret (baywet)https://github.com/baywet
completedhttps://github.com/microsoftgraph/msgraph-sdk-java/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#481https://github.com/microsoftgraph/msgraph-sdk-java/pull/481
on Sep 21, 2020https://github.com/microsoftgraph/msgraph-sdk-java/issues/423#event-3789900182
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoftgraph/msgraph-sdk-java/issues/423
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoftgraph/msgraph-sdk-java/issues/423
Vincent Biret (baywet)https://github.com/baywet
ADO to GitHub automation labelhttps://github.com/microsoftgraph/msgraph-sdk-java/issues?q=state%3Aopen%20label%3A%22ADO%20to%20GitHub%20automation%20label%22
bughttps://github.com/microsoftgraph/msgraph-sdk-java/issues?q=state%3Aopen%20label%3A%22bug%22
fixedhttps://github.com/microsoftgraph/msgraph-sdk-java/issues?q=state%3Aopen%20label%3A%22fixed%22
2.2.0https://github.com/microsoftgraph/msgraph-sdk-java/milestone/5
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.