FileSync/FileSync/B2SDK.cs
/// <summary>
/// Lists all buckets associated with current instance of the SDK
/// </summary>
/// <returns> JSON string of buckets as returned from backblaze API</returns>
Lists all buckets associated with current instance of the SDK
Lists all buckets associated with current instance of the SDK
public List<B2Bucket> b2_list_buckets()
        {
            if (!authorized)
            {
                return null;
            }
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(apiUrl + "/b2api/v1/b2_list_buckets");
            string body = "{\"accountId\":\"" + accountID + "\"}";
            var data = Encoding.UTF8.GetBytes(body);
            webRequest.Method = "POST";
            webRequest.Headers.Add("Authorization", authorizationToken);
            webRequest.ContentType = "application/json; charset=utf-8";
            webRequest.ContentLength = data.Length;
            using (var stream = webRequest.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
                stream.Close();
            }
            WebResponse response = (HttpWebResponse)webRequest.GetResponse();
            var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
            response.Close();
            B2BucketList bucketData = (B2BucketList)Newtonsoft.Json.JsonConvert.DeserializeObject(responseString, typeof(B2BucketList));
            return bucketData.buckets;
        }
public List < B2Bucket > b2_list_buckets ( ) { if ( ! authorized ) { return null ; } HttpWebRequest webRequest = ( HttpWebRequest ) WebRequest . Create ( apiUrl + " " ) ; string body = " \" \" \" " + accountID + " \" " ; var data = Encoding . UTF8 . GetBytes ( body ) ; webRequest . Method = " " ; webRequest . Headers . Add ( " " , authorizationToken ) ; webRequest . ContentType = " " ; webRequest . ContentLength = data . Length ; using ( var stream = webRequest . GetRequestStream ( ) ) { stream . Write ( data , 0 , data . Length ) ; stream . Close ( ) ; } WebResponse response = ( HttpWebResponse ) webRequest . GetResponse ( ) ; var responseString = new StreamReader ( response . GetResponseStream ( ) ) . ReadToEnd ( ) ; response . Close ( ) ; B2BucketList bucketData = ( B2BucketList ) Newtonsoft . Json . JsonConvert . DeserializeObject ( responseString , typeof ( B2BucketList ) ) ; return bucketData . buckets ; }
Lists all buckets associated with current instance of the SDK
Lists all buckets associated with current instance of the SDK
JSON string of buckets as returned from backblaze API
JSON string of buckets as returned from backblaze API