Skip to content

Commit

Permalink
box: implement streaming uploads (see rclone#1614)
Browse files Browse the repository at this point in the history
  • Loading branch information
breunigs committed Aug 19, 2017
1 parent 034cf22 commit e754f50
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions box/box.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,11 @@ func (f *Fs) Put(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.
}
}

// PutStream uploads to the remote path with the modTime given of indeterminate size
func (f *Fs) PutStream(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error) {
return f.Put(in, src, options...)
}

// PutUnchecked the object into the container
//
// This will produce an error if the object already exists
Expand Down Expand Up @@ -977,7 +982,7 @@ func (o *Object) Open(options ...fs.OpenOption) (in io.ReadCloser, err error) {
// upload does a single non-multipart upload
//
// This is recommended for less than 50 MB of content
func (o *Object) upload(in io.Reader, leaf, directoryID string, size int64, modTime time.Time) (err error) {
func (o *Object) upload(in io.Reader, leaf, directoryID string, modTime time.Time) (err error) {
upload := api.UploadFile{
Name: replaceReservedChars(leaf),
ContentModifiedAt: api.Time(modTime),
Expand Down Expand Up @@ -1037,7 +1042,7 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo, options ...fs.OpenOptio

// Upload with simple or multipart
if size <= int64(uploadCutoff) {
err = o.upload(in, leaf, directoryID, size, modTime)
err = o.upload(in, leaf, directoryID, modTime)
} else {
err = o.uploadMultipart(in, leaf, directoryID, size, modTime)
}
Expand All @@ -1053,6 +1058,7 @@ func (o *Object) Remove() error {
var (
_ fs.Fs = (*Fs)(nil)
_ fs.Purger = (*Fs)(nil)
_ fs.PutStreamer = (*Fs)(nil)
_ fs.Copier = (*Fs)(nil)
_ fs.Mover = (*Fs)(nil)
_ fs.DirMover = (*Fs)(nil)
Expand Down

0 comments on commit e754f50

Please sign in to comment.