Skip to content

Commit

Permalink
fix: adjust API paths and add Content-Type for uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
bhunter234 committed Jan 1, 2025
1 parent 85bb0cf commit c96b738
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 6 additions & 5 deletions backend/teldrive/teldrive.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,15 +855,16 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read

fs.FixRangeOption(options, o.size)

streamType := "download"
if o.fs.opt.ThreadedStreams {
streamType = "stream"
}
opts := rest.Opts{
Method: "GET",
Path: fmt.Sprintf("/api/files/%s/%s/%s", o.id, streamType, url.QueryEscape(o.name)),
Path: fmt.Sprintf("/api/files/%s/%s", o.id, url.QueryEscape(o.name)),
Options: options,
}
if !o.fs.opt.ThreadedStreams {
opts.Parameters = url.Values{
"download": []string{"1"},
}
}

err = o.fs.pacer.Call(func() (bool, error) {
resp, err = http.Call(ctx, &opts)
Expand Down
2 changes: 2 additions & 0 deletions backend/teldrive/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func (w *objectChunkWriter) WriteChunk(ctx context.Context, chunkNumber int, rea
Method: "POST",
Body: reader,
ContentLength: &size,
ContentType: "application/octet-stream",
Parameters: url.Values{
"partName": []string{partName},
"fileName": []string{fileName},
Expand Down Expand Up @@ -291,6 +292,7 @@ func (o *Object) uploadMultipart(ctx context.Context, in io.Reader, src fs.Objec
Method: "POST",
Body: partReader,
ContentLength: &n,
ContentType: "application/octet-stream",
Parameters: url.Values{
"partName": []string{chunkName},
"fileName": []string{uploadInfo.fileName},
Expand Down

0 comments on commit c96b738

Please sign in to comment.