public async Task Upload()

in csharp/Microsoft.Azure.Databricks.Client/DbfsApiClient.cs [48:81]


    public async Task Upload(string path, bool overwrite, Stream stream, CancellationToken cancellationToken = default)
    {
        const int mb = 1024 * 1024;
        var handle = await this.Create(path, overwrite, cancellationToken).ConfigureAwait(false);

        var originalPosition = 0L;

        if (stream.CanSeek)
        {
            originalPosition = stream.Position;
            stream.Position = 0;
        }

        var buffer = new byte[mb];
        try
        {
            int bytesRead;
            while ((bytesRead = await stream.ReadAsync(buffer.AsMemory(0, mb), cancellationToken)) > 0)
            {
                var contents = new byte[bytesRead];
                Array.Copy(buffer, contents, bytesRead);
                await this.AddBlock(handle, contents, cancellationToken).ConfigureAwait(false);
            }

            await this.Close(handle, cancellationToken).ConfigureAwait(false);
        }
        finally
        {
            if (stream.CanSeek)
            {
                stream.Position = originalPosition;
            }
        }
    }