Browse Source

解决OBS上传文件出错的问题

feature_gxh
Sydonian 4 months ago
parent
commit
d5d4380823
3 changed files with 11 additions and 7 deletions
  1. +1
    -1
      common/pkgs/storage/s3/base_store.go
  2. +3
    -3
      jcsctl/cmd/getp/getp.go
  3. +7
    -3
      jcsctl/cmd/putp/putp.go

+ 1
- 1
common/pkgs/storage/s3/base_store.go View File

@@ -89,7 +89,7 @@ func (s *BaseStore) Write(pat clitypes.JPath, stream io.Reader, opt types.WriteO
_, err := s.cli.PutObject(context.TODO(), &s3.PutObjectInput{
Bucket: aws.String(s.Bucket),
Key: aws.String(key.String()),
Body: counter,
Body: hashStr,
Metadata: meta,
})
if err != nil {


+ 3
- 3
jcsctl/cmd/getp/getp.go View File

@@ -143,20 +143,20 @@ func getp(c *cobra.Command, ctx *cmd.CommandContext, opt option, args []string)
dir := filepath.Dir(localPath)
err = os.MkdirAll(dir, 0755)
if err != nil {
fmt.Printf("\tx")
fmt.Printf("\tx\n")
return err
}

fileStartTime := time.Now()
file, err := os.OpenFile(localPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
if err != nil {
fmt.Printf("\tx")
fmt.Printf("\tx\n")
return err
}

_, err = io.Copy(file, tr)
if err != nil {
fmt.Printf("\tx")
fmt.Printf("\tx\n")
return err
}



+ 7
- 3
jcsctl/cmd/putp/putp.go View File

@@ -33,13 +33,15 @@ func init() {
c.Flags().BoolVar(&opt.UseID, "id", false, "treat the second argument as package id")
c.Flags().StringVar(&opt.Prefix, "prefix", "", "add prefix to every uploaded file")
c.Flags().BoolVar(&opt.Create, "create", false, "create package if not exists")
c.Flags().Int64Var(&opt.Affinity, "affinity", 0, "affinity user space of the package")
cmd.RootCmd.AddCommand(c)
}

type option struct {
UseID bool
Prefix string
Create bool
UseID bool
Prefix string
Create bool
Affinity int64
}

func putp(c *cobra.Command, ctx *cmd.CommandContext, opt option, args []string) error {
@@ -132,6 +134,7 @@ func putp(c *cobra.Command, ctx *cmd.CommandContext, opt option, args []string)
_, err = ctx.Client.Object().Upload(cliapi.ObjectUpload{
Info: cliapi.ObjectUploadInfo{
PackageID: pkgID,
Affinity: clitypes.UserSpaceID(opt.Affinity),
},
Files: iterator.Array(&cliapi.UploadingObject{
Path: pat,
@@ -156,6 +159,7 @@ func putp(c *cobra.Command, ctx *cmd.CommandContext, opt option, args []string)
_, err = ctx.Client.Object().Upload(cliapi.ObjectUpload{
Info: cliapi.ObjectUploadInfo{
PackageID: pkgID,
Affinity: clitypes.UserSpaceID(opt.Affinity),
},
Files: iter,
})


Loading…
Cancel
Save