func()

in internal/conn/storage/storage.go [168:202]


func (c *Client) Upload(ctx context.Context, id string, b []byte) (*url.URL, error) {
	const contPrefix = "arm-ext-nt"
	var cName string

	if c.fakeUploader != nil {
		return c.fakeUploader.Upload(ctx, id, b)
	}

	if c.contExt == "" {
		cName = fmt.Sprintf("%s-%s", contPrefix, c.now().UTC().Format(time.DateOnly))
	} else {
		cName = fmt.Sprintf("%s-%s-%s", contPrefix, c.contExt, c.now().UTC().Format(time.DateOnly))
	}
	bName := id + ".txt"

	cClient := c.cli.NewContainerClient(cName)
	bClient := cClient.NewBlockBlobClient(bName)

	u, err := url.Parse(bClient.URL())
	if err != nil {
		return nil, fmt.Errorf("URL returend by blob client is not a valid URL: %w", err)
	}

	args := uploadArgs{
		id:     id,
		b:      b,
		cName:  cName,
		bName:  bName,
		upload: bClient,
		create: cClient,
		url:    u,
	}

	return c.upload(ctx, args)
}