Skip to content

Commit

Permalink
added web streaming support (#410)
Browse files Browse the repository at this point in the history
* updated gosdk version

* Remove allocation name

* Remove allocation name

* Update go sdk

* changed how min_lock_demand is calculated

* added web streaming support

* changing to recent gosdk version

* recent gosdk version

* updated gosdk

* updated gosdk

---------

Co-authored-by: dabasov <[email protected]>
Co-authored-by: Areeb Usmani <[email protected]>
Co-authored-by: Areeb Usmani <[email protected]>
  • Loading branch information
4 people authored Apr 28, 2023
1 parent 32bb4be commit 5d9f9c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
16 changes: 10 additions & 6 deletions cmd/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var uploadCmd = &cobra.Command{
localPath := cmd.Flag("localpath").Value.String()
thumbnailPath := cmd.Flag("thumbnailpath").Value.String()
encrypt, _ := cmd.Flags().GetBool("encrypt")
webStreaming, _ := cmd.Flags().GetBool("web-streaming")

wg := &sync.WaitGroup{}
statusBar := &StatusBar{wg: wg}
Expand All @@ -62,6 +63,7 @@ var uploadCmd = &cobra.Command{
thumbnailPath: thumbnailPath,
remotePath: remotePath,
encrypt: encrypt,
webStreaming: webStreaming,
chunkNumber: uploadChunkNumber,
// isUpdate: false,
// isRepair: false,
Expand All @@ -81,10 +83,11 @@ type chunkedUploadArgs struct {
remotePath string
thumbnailPath string

encrypt bool
chunkNumber int
isUpdate bool
isRepair bool
encrypt bool
webStreaming bool
chunkNumber int
isUpdate bool
isRepair bool
}

func startChunkedUpload(cmd *cobra.Command, allocationObj *sdk.Allocation, args chunkedUploadArgs, statusBar sdk.StatusCallback) error {
Expand All @@ -101,6 +104,7 @@ func startChunkedUpload(cmd *cobra.Command, allocationObj *sdk.Allocation, args
}

mimeType, err := zboxutil.GetFileContentType(fileReader)

if err != nil {
return err
}
Expand Down Expand Up @@ -128,7 +132,7 @@ func startChunkedUpload(cmd *cobra.Command, allocationObj *sdk.Allocation, args
chunkedUpload, err := sdk.CreateChunkedUpload(util.GetHomeDir(), allocationObj,
fileMeta, fileReader,
args.isUpdate, args.isRepair,
options...)
args.webStreaming, options...)

if err != nil {
return err
Expand All @@ -146,7 +150,7 @@ func init() {
uploadCmd.PersistentFlags().String("thumbnailpath", "", "Local thumbnail path of file to upload")
uploadCmd.PersistentFlags().String("attr-who-pays-for-reads", "owner", "Who pays for reads: owner or 3rd_party")
uploadCmd.Flags().Bool("encrypt", false, "pass this option to encrypt and upload the file")

uploadCmd.Flags().Bool("web-streaming", false, "pass this option to enable web streaming support")
uploadCmd.Flags().IntVarP(&uploadChunkNumber, "chunknumber", "", 1, "how many chunks should be uploaded in a http request")

uploadCmd.MarkFlagRequired("allocation")
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/0chain/errors v1.0.3
github.com/0chain/gosdk v1.8.16-0.20230427161011-6fb50cdcb352
github.com/0chain/gosdk v1.8.16-0.20230428181609-f0d08895c0f1
github.com/icza/bitio v1.1.0
github.com/olekukonko/tablewriter v0.0.5
github.com/spf13/cobra v1.6.0
Expand Down Expand Up @@ -69,4 +69,4 @@ require (
)

// temporary, for development
// replace github.com/0chain/gosdk => ../gosdk
//replace github.com/0chain/gosdk => ../gosdk
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs
github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E=
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
github.com/0chain/gosdk v1.8.16-0.20230427161011-6fb50cdcb352 h1:2zPXNeHLBInsKXOJAFWrRzUpDwfZD9HRXGiCNFRKHFw=
github.com/0chain/gosdk v1.8.16-0.20230427161011-6fb50cdcb352/go.mod h1:z4IjdbQz1dhcM6wdKQWjUYmHoQw3k44QNatb+vdKFAA=
github.com/0chain/gosdk v1.8.16-0.20230428181609-f0d08895c0f1 h1:RbqutI1emZ8FID51ZGyJTs9r6+kAl+nKund5enUzR9g=
github.com/0chain/gosdk v1.8.16-0.20230428181609-f0d08895c0f1/go.mod h1:z4IjdbQz1dhcM6wdKQWjUYmHoQw3k44QNatb+vdKFAA=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw=
Expand Down

0 comments on commit 5d9f9c5

Please sign in to comment.