35 lines
534 B
Go
35 lines
534 B
Go
|
package blob
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/pkg/errors"
|
||
|
)
|
||
|
|
||
|
type WriteBlobArgs struct {
|
||
|
WriterID WriterID
|
||
|
Data []byte
|
||
|
}
|
||
|
|
||
|
type WriteBlobReply struct {
|
||
|
Written int
|
||
|
}
|
||
|
|
||
|
func (s *Service) WriteBlob(ctx context.Context, args *WriteBlobArgs, reply *WriteBlobReply) error {
|
||
|
writer, err := s.getOpenedWriter(args.WriterID)
|
||
|
if err != nil {
|
||
|
return errors.WithStack(err)
|
||
|
}
|
||
|
|
||
|
written, err := writer.Write(args.Data)
|
||
|
if err != nil {
|
||
|
return errors.WithStack(err)
|
||
|
}
|
||
|
|
||
|
*reply = WriteBlobReply{
|
||
|
Written: written,
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|