// NewTempArchive reads the content of src into a temporary file, and returns the contents
// of that file as an archive. The archive can only be read once - as soon as reading completes,
// the file will be deleted.
NewTempArchive reads the content of src into a temporary file, and returns the contents
of that file as an archive. The archive can only be read once - as soon as reading completes,
the file will be deleted.
// NewTempArchive reads the content of src into a temporary file and returns the contents // of that file as an archive . The archive can only be read once - as soon as reading completes // the file will be deleted .
func NewTempArchive(src io.Reader, dir string) (*TempArchive, error) {
        f, err := ioutil.TempFile(dir, "")
        if err != nil {
                return nil, err
        }
        if _, err := io.Copy(f, src); err != nil {
                return nil, err
        }
        if _, err := f.Seek(0, 0); err != nil {
                return nil, err
        }
        st, err := f.Stat()
        if err != nil {
                return nil, err
        }
        size := st.Size()
        return &TempArchive{File: f, Size: size}, nil
}
func NewTempArchive ( src io . Reader , dir string ) ( * TempArchive , error ) { f , err := ioutil . TempFile ( dir , " " ) if err != nil { return nil , err } if _ , err := io . Copy ( f , src ) ; err != nil { return nil , err } if _ , err := f . Seek ( 0 , 0 ) ; err != nil { return nil , err } st , err := f . Stat ( ) if err != nil { return nil , err } size := st . Size ( ) return & TempArchive { File : f , Size : size } , nil }
NewTempArchive reads the content of src into a temporary file, and returns the contents
of that file as an archive.
NewTempArchive reads the content of src into a temporary file and returns the contents of that file as an archive .