-
Notifications
You must be signed in to change notification settings - Fork 71
Description
First of all, thanks for this very cool library!
I have a feature request/ proposal for the following usecase:
I have a custom server implementation, which will give the same upload endpoint, if it believes the files are the same (i.e. the POST
/files/redirects to/files/someHashfor every file that matches a specific test - since those file are actually identical).
I can't solve this using the fingerprint system, since the two uploads might be done from two different computers and the fingerprint is computed by the server.
This library works fine if the upload not started before, but it doesn't work if a part of the file has been already uploaded (ErrOffsetMismatch).
I would like to add an option to the config (RequestOffsetOnUploadCreation) to tell the client to getUploadOffset on CreateUpload.
Change would be like:
diff --git a/client.go b/client.go
index b5923d1..1b43b2c 100644
--- a/client.go
+++ b/client.go
@@ -110,7 +110,17 @@ func (c *Client) CreateUpload(u *Upload) (*Uploader, error) {
c.Config.Store.Set(u.Fingerprint, url)
}
- return NewUploader(c, url, u, 0), nil
+ var offset int64
+
+ if c.Config.RequestOffsetOnUploadCreation {
+ offset, err = c.getUploadOffset(url)
+
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ return NewUploader(c, url, u, offset), nil
case 412:
return nil, ErrVersionMismatch
case 413:What do you think ?
Can I make a PR with this change ? Do you have an idea for a name, better than RequestOffsetOnUploadCreation ?