Skip to content

SetFileFragment

Sets the fragment size for uploading the request body in parts.

1
myRestRequest.SetFileFragment(size: number):RestRequest

Parameters

number size
    The size of each fragment, in bytes.

Returns

The current RestRequest instance.

Remarks

This method is used to send file uploads in small fragments (chunks).

Before using this method, ensure that the target REST service supports the "Content-Range" header.

Examples

Upload a large file in 5 MB parts

1
2
3
4
5
6
7
8
var request = $Rest.Create('https://files.example.com/')
    .Request('upload/{name}')
    .AddUrlParameter('name', 'backup.zip')
    .AddFileBody($Xml.Evaluate('BackupFile'))
    .SetFileFragment(5 * 1024 * 1024);

request.Method = 'Put';
request.Execute().Verify();

See Also