SiaFoundation / renterd

A renter for Sia
https://sia.tech/software/renterd
MIT License
68 stars 20 forks source link

Add Content-Range support to the PUT api/worker/objects/:key Endpoint #1165

Open daniel-lucio opened 7 months ago

daniel-lucio commented 7 months ago

Description

When doing an API call like this: PUT /api/worker/objects%2F1536-f.txt?bucket=default HTTP/1.1

and passing headers like this:

Content-Length: 2477
Content-Type: application/octet-stream
Content-Range: bytes 4096-6573/

the renterd API should honour and accept the Range. Currently, it ignores it and when sending a file in 2 ranges, the second range overwrites the first one.

This would make easier the coding for the siafs (grant). Also, it is a good idea to keep the API to honour the HTTP headers when dealing with files.

Version

v1.0.6

What operating system are you running (e.g. Ubuntu 22.04, macOS, Windows 11)?

Linux

Anything else?

RFC: https://datatracker.ietf.org/doc/html/rfc7233#section-4.2

Log:

> PUT /api/worker/objects/1536-f.txt?bucket=default HTTP/1.1
Host: 192.168.7.52:9880
Authorization: Basic OXXXXXXX==
Accept: */*
Content-Length: 2477
Content-Type: application/octet-stream
Content-Range: bytes 4096-6573/*
ChrisSchinnerl commented 6 months ago

Sia in its current state doesn't support updating ranges of files and therefore ignores the Content-Range header. For uploading an object in chunks you can use the multipart API but updating already uploaded objects isn't currently on our roadmap.