MCPcopy Create free account
hub / github.com/UiPath/uipathcli / Upload

Method Upload

utils/api/orchestrator_client.go:82–102  ·  view source on GitHub ↗
(file stream.Stream, feedId string, uploadBar *visualization.ProgressBar)

Source from the content-addressed store, hash-verified

80}
81
82func (c OrchestratorClient) Upload(file stream.Stream, feedId string, uploadBar *visualization.ProgressBar) error {
83 context, cancel := context.WithCancelCause(context.Background())
84 request := c.createUploadRequest(file, feedId, uploadBar, cancel)
85 client := network.NewHttpClient(c.logger, c.httpClientSettings())
86 response, err := client.SendWithContext(request, context)
87 if err != nil {
88 return err
89 }
90 defer func() { _ = response.Body.Close() }()
91 body, err := io.ReadAll(response.Body)
92 if err != nil {
93 return fmt.Errorf("Error reading response: %w", err)
94 }
95 if response.StatusCode == http.StatusConflict {
96 return ErrPackageAlreadyExists
97 }
98 if response.StatusCode != http.StatusOK {
99 return fmt.Errorf("Orchestrator returned status code '%v' and body '%v'", response.StatusCode, string(body))
100 }
101 return nil
102}
103
104func (c OrchestratorClient) createUploadRequest(file stream.Stream, feedId string, uploadBar *visualization.ProgressBar, cancel context.CancelCauseFunc) *network.HttpRequest {
105 bodyReader, bodyWriter := io.Pipe()

Callers 2

runTestsMethod · 0.95
publishMethod · 0.95

Calls 5

createUploadRequestMethod · 0.95
httpClientSettingsMethod · 0.95
SendWithContextMethod · 0.95
NewHttpClientFunction · 0.92
CloseMethod · 0.80

Tested by

no test coverage detected