@@ -74,6 +74,8 @@ type Options struct {
74
74
75
75
// Set to true to use the local disk as a buffer for chunk
76
76
// writes to EOS. Default is false, i.e. pure streaming
77
+ // Beware: in pure streaming mode the FST must support
78
+ // the HTTP chunked encoding
77
79
WriteUsesLocalTemp bool
78
80
79
81
// Location of the xrdcopy binary.
@@ -1198,8 +1200,10 @@ func (c *Client) Read(ctx context.Context, uid, gid, path string) (io.ReadCloser
1198
1200
func (c * Client ) Write (ctx context.Context , uid , gid , path string , stream io.ReadCloser ) error {
1199
1201
log := appctx .GetLogger (ctx )
1200
1202
log .Info ().Str ("func" , "Write" ).Str ("uid,gid" , uid + "," + gid ).Str ("path" , path ).Msg ("" )
1203
+ var length int64
1204
+ length = - 1
1201
1205
1202
- if c .opt .ReadUsesLocalTemp {
1206
+ if c .opt .WriteUsesLocalTemp {
1203
1207
fd , err := ioutil .TempFile (c .opt .CacheDirectory , "eoswrite-" )
1204
1208
if err != nil {
1205
1209
return err
@@ -1209,7 +1213,7 @@ func (c *Client) Write(ctx context.Context, uid, gid, path string, stream io.Rea
1209
1213
1210
1214
log .Info ().Str ("func" , "Write" ).Str ("uid,gid" , uid + "," + gid ).Str ("path" , path ).Str ("tempfile" , fd .Name ()).Msg ("" )
1211
1215
// copy stream to local temp file
1212
- _ , err = io .Copy (fd , stream )
1216
+ length , err = io .Copy (fd , stream )
1213
1217
if err != nil {
1214
1218
return err
1215
1219
}
@@ -1221,10 +1225,10 @@ func (c *Client) Write(ctx context.Context, uid, gid, path string, stream io.Rea
1221
1225
defer wfd .Close ()
1222
1226
defer os .RemoveAll (fd .Name ())
1223
1227
1224
- return c .GetHTTPCl ().PUTFile (ctx , "" , uid , gid , path , wfd )
1228
+ return c .GetHTTPCl ().PUTFile (ctx , "" , uid , gid , path , wfd , length )
1225
1229
}
1226
1230
1227
- return c .GetHTTPCl ().PUTFile (ctx , "" , uid , gid , path , stream )
1231
+ return c .GetHTTPCl ().PUTFile (ctx , "" , uid , gid , path , stream , length )
1228
1232
1229
1233
// return c.GetHttpCl().PUTFile(ctx, remoteuser, uid, gid, urlpathng, stream)
1230
1234
// return c.WriteFile(ctx, uid, gid, path, fd.Name())
0 commit comments