MCPcopy Index your code
hub / github.com/peak/s5cmd / validatePipeCommand

Function validatePipeCommand

command/pipe.go:291–317  ·  view source on GitHub ↗
(c *cli.Context)

Source from the content-addressed store, hash-verified

289}
290
291func validatePipeCommand(c *cli.Context) error {
292 if c.Args().Len() != 1 {
293 return fmt.Errorf("expected destination argument")
294 }
295
296 dst := c.Args().Get(0)
297
298 dsturl, err := url.New(dst, url.WithRaw(c.Bool("raw")))
299 if err != nil {
300 return err
301 }
302
303 if !dsturl.IsRemote() {
304 return fmt.Errorf("destination must be a bucket")
305 }
306
307 if dsturl.IsBucket() || dsturl.IsPrefix() {
308 return fmt.Errorf("target %q must be an object", dsturl)
309 }
310
311 // wildcard destination can not be used with pipe
312 if dsturl.IsWildcard() {
313 return fmt.Errorf("target %q can not contain glob characters", dst)
314 }
315
316 return nil
317}
318
319func guessContentTypeByExtension(dsturl *url.URL) string {
320 contentType := mime.TypeByExtension(filepath.Ext(dsturl.Absolute()))

Callers 1

NewPipeCommandFunction · 0.85

Calls 7

NewFunction · 0.92
WithRawFunction · 0.92
IsRemoteMethod · 0.80
IsBucketMethod · 0.80
IsPrefixMethod · 0.80
IsWildcardMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected