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

Method StartDigitization

utils/api/du_client.go:33–55  ·  view source on GitHub ↗
(projectId string, file stream.Stream, contentType string, uploadBar *visualization.ProgressBar)

Source from the content-addressed store, hash-verified

31}
32
33func (c DuClient) StartDigitization(projectId string, file stream.Stream, contentType string, uploadBar *visualization.ProgressBar) (string, error) {
34 context, cancel := context.WithCancelCause(context.Background())
35 request := c.createStartDigitizationRequest(projectId, file, contentType, uploadBar, cancel)
36 client := network.NewHttpClient(c.logger, c.httpClientSettings())
37 response, err := client.SendWithContext(request, context)
38 if err != nil {
39 return "", err
40 }
41 defer func() { _ = response.Body.Close() }()
42 body, err := io.ReadAll(response.Body)
43 if err != nil {
44 return "", fmt.Errorf("Error reading response: %w", err)
45 }
46 if response.StatusCode != http.StatusAccepted {
47 return "", fmt.Errorf("Digitizer returned status code '%v' and body '%v'", response.StatusCode, string(body))
48 }
49 var result digitizeResponse
50 err = json.Unmarshal(body, &result)
51 if err != nil {
52 return "", fmt.Errorf("Error parsing json response: %w", err)
53 }
54 return result.DocumentId, nil
55}
56
57func (c DuClient) createStartDigitizationRequest(projectId string, file stream.Stream, contentType string, uploadBar *visualization.ProgressBar, cancel context.CancelCauseFunc) *network.HttpRequest {
58 streamSize, _ := file.Size()

Callers 1

startDigitizationMethod · 0.95

Calls 5

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

Tested by

no test coverage detected