MCPcopy Index your code
hub / github.com/linuxkit/linuxkit / UploadFile

Method UploadFile

src/cmd/linuxkit/gcp.go:110–131  ·  view source on GitHub ↗

UploadFile uploads a file to Google Storage

(src, dst, bucketName string, public bool)

Source from the content-addressed store, hash-verified

108
109// UploadFile uploads a file to Google Storage
110func (g GCPClient) UploadFile(src, dst, bucketName string, public bool) error {
111 log.Infof("Uploading file %s to Google Storage as %s", src, dst)
112 f, err := os.Open(src)
113 if err != nil {
114 return err
115 }
116 defer func() { _ = f.Close() }()
117
118 objectCall := g.storage.Objects.Insert(bucketName, &storage.Object{Name: dst}).Media(f)
119
120 if public {
121 objectCall.PredefinedAcl("publicRead")
122 }
123
124 _, err = objectCall.Do()
125 if err != nil {
126 return err
127 }
128 log.Infof("Upload Complete!")
129 fmt.Println("gs://" + bucketName + "/" + dst)
130 return nil
131}
132
133// CreateImage creates a GCP image using the source from Google Storage
134func (g GCPClient) CreateImage(name, storageURL, family string, nested, uefi, replace bool) error {

Callers 2

pushGCPCmdFunction · 0.95
uploadFileFunction · 0.80

Calls 3

DoMethod · 0.80
OpenMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected