5047

Chunked Upload Session

Integrations
Medium
Pro
interface
json
rest
http
upload

Chunked Upload Session

Your extension archives posted invoice documents to the company's document service — a Graph-style API where a large file never goes up in one request. The protocol is the one every cloud storage API speaks: open an upload session, then stream the file in fixed-size slices until the server says it has everything. Get one offset wrong and the server rejects the transfer; lose your nerve on a transient failure and the file arrives with a hole in it.

The service works like this: a POST creates the session and hands back a one-time uploadUrl; each following PUT carries one chunk and declares exactly which slice of the file it is in a Content-Range header. 202 means "stored, keep going", 201 means "file committed". Mid-transfer the service occasionally answers 500 — that chunk was thrown away and must be sent again.

Grading runs inside a container with no outbound network, so the client never talks HTTP itself: it goes through a small transport interface whose production implementation would wrap HttpClient, and whose grading implementation is a mock service the tests control. Your upload logic must not care which one it is handed.

Requirements

Create an interface named "Upload Transport" with exactly this declaration:

interface "Upload Transport"
{
    procedure CreateSession(SessionUrl: Text): Text;
    procedure PutChunk(UploadUrl: Text; ContentRange: Text; ChunkContent: Text; var ResponseBody: Text): Integer;
}

CreateSession performs the POST that opens the session and returns the raw JSON response body. PutChunk performs one PUT of one chunk: ContentRange is the header value, ChunkContent is the chunk's characters, ResponseBody receives the response body, and the return value is the HTTP status code.

The rest of the statement and 3 hints Unlock with Pro
ALBusiness Central 28.5
Pro
Pro problem

Solve it with Pro

You’re reading the opening of the statement. Pro unlocks the whole problem:

  • The full statement
  • Starter code in the browser editor
  • 7 grading tests, run on Business Central 28.5
  • 3 hints
  • The reference solution

Pro also opens all 92 Pro problems and lifts the daily limits on compile checks and submissions.

$10 / month
or $100 / year
Upgrade
This problem is part of Pro
Pro unlocks the full statement, tests, hints and solution. The code editor works on a computer.
Upgrade