func()

in internal/conn/storage/storage.go [227:258]


func (c *Client) upload(ctx context.Context, args uploadArgs) (*url.URL, error) {
	cred, err := c.creds.get(ctx)
	if err != nil {
		return nil, err
	}

	// TODO: It would be better if we check for the existence of the container
	// before trying to create it.  It wasn't immediately obvious how to do that.
	_, err = args.upload.UploadBuffer(ctx, args.b, nil)
	if err := handleUploadErr(ctx, err, args.create); err != nil {
		return nil, err
	}

	sigVals := sas.BlobSignatureValues{
		Protocol:      sas.ProtocolHTTPS,
		StartTime:     time.Now().UTC().Add(time.Second * -10),
		ExpiryTime:    c.now().UTC().Add(7 * 24 * time.Hour),
		Permissions:   (&sas.BlobPermissions{Read: true}).String(),
		ContainerName: args.cName,
		BlobName:      args.bName,
	}

	c.log.Debug(fmt.Sprintf("Uploading to blob. Container: %s, Blob: %s", args.cName, args.bName))

	enc, err := c.signParams(sigVals, cred)
	if err != nil {
		return nil, err
	}

	args.url.RawQuery = enc.Encode()
	return args.url, nil
}