Documentation ¶
Index ¶
- type ExtraFileInfo
- type ExtraFileItem
- type ExtraFilesInfo
- type Status
- type Uploader
- func (u *Uploader) NewUploadSession(ctx context.Context, fname string, fsize int64, profiles string, ...) (*sdk.UploadSession, error)
- func (u *Uploader) Upload(ctx context.Context, r io.ReaderAt, filename string, size int64, ...) error
- func (u *Uploader) UploadSession(ctx context.Context, s *sdk.UploadSession, r io.ReaderAt, size int64, ...) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExtraFileInfo ¶
type ExtraFileInfo struct { Tag string Files []ExtraFileItem }
type ExtraFilesInfo ¶
type ExtraFilesInfo []ExtraFileInfo
func (ExtraFilesInfo) ConvertToExtraFiles ¶
func (efi ExtraFilesInfo) ConvertToExtraFiles() []sdk.ExtraFile
type Status ¶
type Status struct {
MissingParts []int `json:"missing_parts"`
}
Status describes the object returned from the upload API. Upload Status contains a slice of part numbers which are still missing.
type Uploader ¶
type Uploader struct { // DebugLog specifies an optional logger for any events which take place // during the upload. DebugLog *log.Logger MediaID string // contains filtered or unexported fields }
Uploader takes care of multi-chunk file upload to Telestream Cloud. It can be reused after every upload.
func (*Uploader) NewUploadSession ¶
func (u *Uploader) NewUploadSession(ctx context.Context, fname string, fsize int64, profiles string, extraFiles []sdk.ExtraFile) (*sdk.UploadSession, error)
NewUploadSession creates new upload UploadSession which gives a unique resource location to upload the file. These UploadSessions are being created with multi-chunk option.
func (*Uploader) Upload ¶
func (u *Uploader) Upload(ctx context.Context, r io.ReaderAt, filename string, size int64, profiles string, extraFilesInfo *ExtraFilesInfo) error
Upload is a short version of UploadSession. It takes care of creating UploadSessions and immediately starts the file upload.
Example ¶
f, err := os.Open("video.mp4") if err != nil { fmt.Println(err) os.Exit(1) } fi, err := f.Stat() if err != nil { fmt.Println(err) os.Exit(1) } cl := client.Client{ Host: "api.cloud.telestream.net:443", Options: &client.Options{ AccessKey: "access_key", SecretKey: "secret_key", }, } u, err := uploader.New(&cl, "factoryID") if err != nil { fmt.Println(err) os.Exit(1) } profiles := []string{"h264"} // To setup a debug Log: // // u.DebugLog = log.New(os.Stdout, "", log.LstdFlags) // if err := u.Upload(f, fi.Name(), fi.Size(), profiles, nil); err != nil { fmt.Println(err) os.Exit(1) }
Output:
func (*Uploader) UploadSession ¶
func (u *Uploader) UploadSession(ctx context.Context, s *sdk.UploadSession, r io.ReaderAt, size int64, extraFiles *ExtraFilesInfo) error
UploadSession uploads files based on the given sdk.UploadSession. If the upload has failed or has been stopped, it is possible to resume it using this method. Uploading stops on the first worker error and returns it.
Example ¶
f, err := os.Open("video.mp4") if err != nil { fmt.Println(err) os.Exit(1) } fi, err := f.Stat() if err != nil { fmt.Println(err) os.Exit(1) } cl := client.Client{ Host: "api.cloud.telestream.net:443", Options: &client.Options{ AccessKey: "access_key", SecretKey: "secret_key", }, } u, err := uploader.New(&cl, "factoryID") if err != nil { fmt.Println(err) os.Exit(1) } profiles := []string{"h264"} s, err := u.NewSession(fi.Name(), fi.Size(), profiles, nil) if err != nil { fmt.Println(err) os.Exit(1) } if err := u.UploadSession(s, f, fi.Size(), nil); err != nil { fmt.Println(err) os.Exit(1) }
Output: