-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update FAQ and restructure readme (#20)
* update readme with faqs * fix markdown lint * add generic readertoseeker implmentation * fix seeker * add reader
- Loading branch information
Showing
3 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package gulter | ||
|
||
import ( | ||
"io" | ||
"os" | ||
) | ||
|
||
func ReaderToSeeker(r io.Reader) (io.ReadSeeker, error) { | ||
tmpfile, err := os.CreateTemp("", "upload-") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
_, err = io.Copy(tmpfile, r) | ||
if err != nil { | ||
_ = tmpfile.Close() | ||
_ = os.Remove(tmpfile.Name()) | ||
return nil, err | ||
} | ||
|
||
_, err = tmpfile.Seek(0, 0) | ||
if err != nil { | ||
_ = tmpfile.Close() | ||
_ = os.Remove(tmpfile.Name()) | ||
return nil, err | ||
} | ||
|
||
// Return the file, which implements io.ReadSeeker | ||
// which you can now pass to the gulter uploader | ||
return tmpfile, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters