Пример #1
0
        private static async Task<int> ExecuteAsync(Options options)
        {
            // build the implementation models
            using (var stdin = Console.OpenStandardInput())
            {
                var client = new Client(new SystemTime(), new PathBuilder());

                if (options.OnlyUnique)
                {
                    var uniqueClient = new UniqueClient(client);

                    // we have to buffer the input for byte-by-byte comparison
                    using (var buffer = new MemoryStream())
                    {
                        await stdin.CopyToAsync(buffer);
                        buffer.Seek(0, SeekOrigin.Begin);

                        var request = new UniqueUploadRequest
                        {
                            ConnectionString = options.ConnectionString,
                            Container = options.Container,
                            ContentType = options.ContentType,
                            PathFormat = options.PathFormat,
                            Stream = buffer,
                            EqualsAsync = null,
                            UploadDirect = !options.NoDirect,
                            Trace = Console.Out
                        };

                        // upload
                        await uniqueClient.UploadAsync(request);
                    }

                }
                else
                {
                    var request = new UploadRequest
                    {
                        ConnectionString = options.ConnectionString,
                        Container = options.Container,
                        ContentType = options.ContentType,
                        PathFormat = options.PathFormat,
                        UploadDirect = !options.NoDirect,
                        UploadLatest = !options.NoLatest,
                        Stream = stdin,
                        Trace = Console.Out
                    };

                    // upload
                    await client.UploadAsync(request);
                }

            }

            return 0;
        }