Exemple #1
0
        static void Main(string[] args)
        {
            try
            {
                Client = BackblazeClient.Initialize("[key_id]", "[application_key]");

                var buckets = Client.Buckets.GetAsync().GetAwaiter().GetResult();

                foreach (var bucket in buckets)
                {
                    Console.WriteLine($"Bucket Name: {bucket.BucketName} - Type: {bucket.BucketType}");
                }

                foreach (var filepath in Directory.GetFiles(@"c:\my\directory"))
                {
                    using (var stream = File.OpenRead(filepath)) {
                        var results = Client.UploadAsync(buckets.ToList().First().BucketId, new FileInfo(filepath).Name, stream).GetAwaiter().GetResult();
                        Console.WriteLine(results.Response.FileName);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
            }
        }
Exemple #2
0
        public async Task Client_InitializeWithAppKey()
        {
            var request = new CreateKeyRequest(Client.AccountId, _keyName, Capabilities.ReadOnly());
            var results = await Client.Keys.CreateAsync(request);

            results.EnsureSuccessStatusCode();

            var options = results.Response;
            var client  = BackblazeClient.Initialize(options.ApplicationKeyId, options.ApplicationKey);

            var findResults = await client.Buckets.FindByNameAsync(_bucketName);

            Assert.Equal(_bucketName, findResults.BucketName);

            var deleteResults = await Client.Keys.DeleteAsync(options.ApplicationKeyId);

            Assert.Equal(typeof(DeleteKeyResponse), deleteResults.Response.GetType());
            Assert.Equal(Capabilities.ReadOnly(), deleteResults.Response.Capabilities);
        }
Exemple #3
0
 public ClientTest(StorageClientFixture fixture)
     : base(fixture)
 {
     Client = BackblazeClient.Initialize(Options.KeyId, Options.ApplicationKey);
 }