You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 30, 2022. It is now read-only.
Provide a function which allows to open files from the remote server and read from them via an io.Reader.
Description
The proposed function ReceiveOpen returns a FileInfo to the caller similar to Receive. The difference to Receive is, that writing to an io.Writer provided by the caller, the caller gets an io.Reader.
The main advantage is that it provides the consumer more control over reading process. This would allow better integration of go-scp with other golang modules. For example, the io.Reader can be wrapped in high level Reader implementations provided by the io package.
Proposed changes
Add the function ReceiveOpen:
// ReceiveOpen returns a FileInfo and a ReadCloserfunc (*SCP) ReceiveOpen(srcFilestring) (*FileInfo, io.ReadCloser, error)
Example usage
// Open file on remote serverreader, fileInfo, err:=scp.NewSCP(c).ReceiveOpen(remotePath)
deferreader.Close()
iferr!=nil {
panic(err)
}
// Read file data into slicedata, err:=ioutil.ReadAll(reader)
iferr!=nil {
panic(err)
}
The text was updated successfully, but these errors were encountered:
Provide a function which allows to open files from the remote server and read from them via an
io.Reader
.Description
The proposed function
ReceiveOpen
returns aFileInfo
to the caller similar toReceive
. The difference toReceive
is, that writing to anio.Writer
provided by the caller, the caller gets anio.Reader
.The main advantage is that it provides the consumer more control over reading process. This would allow better integration of
go-scp
with other golang modules. For example, theio.Reader
can be wrapped in high level Reader implementations provided by theio
package.Proposed changes
Add the function
ReceiveOpen
:Example usage
The text was updated successfully, but these errors were encountered: