upload

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Copyright © 2022 University of Pennsylvania <support@server>>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright © 2022 University of Pennsylvania <support@server>>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var CancelCmd = &cobra.Command{
	Use:   "cancel",
	Short: "Cancel upload session.",
	Long:  `Cancel upload session.`,
	Run: func(cmd *cobra.Command, args []string) {

		selectedManifest, err := cmd.Flags().GetInt32("manifest_id")
		if err != nil {
			log.Fatalln("Error getting manifest flag from command line: ", err)
		}

		cancelAll := false

		req := pb.CancelUploadRequest{
			ManifestId: selectedManifest,
			CancelAll:  cancelAll,
		}

		port := viper.GetString("agent.port")

		conn, err := grpc.Dial(":"+port, grpc.WithTransportCredentials(insecure.NewCredentials()))
		if err != nil {
			fmt.Println("Error connecting to GRPC Server: ", err)
		}
		defer conn.Close()

		client := pb.NewAgentClient(conn)
		uploadResponse, err := client.CancelUpload(context.Background(), &req)
		if err != nil {
			fmt.Println("Error uploading file: ", err)
		}
		fmt.Println(uploadResponse)

	},
}
View Source
var ManifestCmd = &cobra.Command{
	Use:   "manifest <manifestId>",
	Short: "Upload files to the Pennsieve platform.",
	Long:  `Upload files to the Pennsieve platform.`,
	Args:  cobra.MinimumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {

		i, err := strconv.ParseInt(args[0], 10, 32)
		if err != nil {
			panic(err)
		}
		manifestId := int32(i)

		fmt.Println("CMD: Manifest ID:", manifestId)

		req := pb.UploadManifestRequest{
			ManifestId: manifestId,
		}

		port := viper.GetString("agent.port")

		conn, err := grpc.Dial(":"+port, grpc.WithTransportCredentials(insecure.NewCredentials()))
		if err != nil {
			fmt.Println("Error connecting to GRPC Server: ", err)
		}
		defer conn.Close()

		client := pb.NewAgentClient(conn)
		_, err = client.UploadManifest(context.Background(), &req)
		if err != nil {
			fmt.Println("Error uploading file: ", err)
		}

		fmt.Println(fmt.Sprintf("\nUpload initiated for manifest: %d\n\nUse "+
			"\"pennsieve-agent agent subscribe\" to track progress of the uploaded files.\n\n"+
			"Use \"pennsieve-agent upload cancel %d\" to cancel the current upload session.", manifestId, manifestId))
	},
}
View Source
var UploadCmd = &cobra.Command{
	Use:   "upload [flags] [PATH] [...PATH]",
	Short: "Upload files to the Pennsieve platform.",
	Long:  `Upload files to the Pennsieve platform.`,
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		config.InitDB()
	},
}

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