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

Method upload

plugin/orchestrator/upload/upload_command.go:49–68  ·  view source on GitHub ↗
(ctx plugin.ExecutionContext, logger log.Logger, url string)

Source from the content-addressed store, hash-verified

47}
48
49func (c UploadCommand) upload(ctx plugin.ExecutionContext, logger log.Logger, url string) error {
50 uploadBar := visualization.NewProgressBar(logger)
51 defer uploadBar.Remove()
52 context, cancel := context.WithCancelCause(context.Background())
53 request := c.createUploadRequest(ctx, url, uploadBar, cancel)
54 client := network.NewHttpClient(logger, c.httpClientSettings(ctx))
55 response, err := client.SendWithContext(request, context)
56 if err != nil {
57 return err
58 }
59 defer func() { _ = response.Body.Close() }()
60 body, err := io.ReadAll(response.Body)
61 if err != nil {
62 return fmt.Errorf("Error reading response: %w", err)
63 }
64 if response.StatusCode != http.StatusCreated {
65 return fmt.Errorf("Orchestrator returned status code '%v' and body '%v'", response.StatusCode, string(body))
66 }
67 return nil
68}
69
70func (c UploadCommand) createUploadRequest(ctx plugin.ExecutionContext, url string, uploadBar *visualization.ProgressBar, cancel context.CancelCauseFunc) *network.HttpRequest {
71 file := ctx.Input

Callers 1

ExecuteMethod · 0.95

Calls 7

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

Tested by

no test coverage detected