upload

package
v0.81.0-dev-3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "upload <file>",
	Short: "Upload file to S3",
	Args:  cobra.ExactArgs(1),
	Run: func(c *cobra.Command, args []string) {
		filePath := args[0]
		f, err := os.Open(filePath)
		if err != nil {
			log.Fatalln(err)
		}

		accessKey, secretKey, region,
			endpoint, bucketName := s3_utils.GetS3SecretsFromVaultOrEnvOrDie("secret/data/slu/upload")

		key := time_utils.NowForFileName() + "_" + filePath

		err = s3_utils.Upload(
			accessKey,
			secretKey,
			region,
			endpoint,
			bucketName,
			key,
			f,
		)
		if err != nil {
			log.Fatalln(err)
		}
		url, err := s3_utils.GetObjectPresignUrl(
			accessKey,
			secretKey,
			region,
			endpoint,
			bucketName,
			key,
			24*time.Hour,
		)
		if err != nil {
			log.Fatalln(err)
		}
		fmt.Printf("Key:              %s\n", key)
		fmt.Printf("Download (1 day): %s\n", url)
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL