FileSync/FileSync/B2SDK.cs
/// <summary>
/// Gets versions of every file in a bucket starting with the start file name
/// </summary>
/// <param name="bucketId"> id of bucket to search</param>
/// <param name="startFileName"> starting file name for files</param>
/// <returns> B2FileList -- list of files in bucket </returns>
Gets versions of every file in a bucket starting with the start file name
Gets versions of every file in a bucket starting with the start file name
public B2FileList b2_list_file_versions(string bucketId, string startFileName)
        {
            if (!checkStringParamsNotEmpty(new string[] { bucketId }) || !authorized)
            {
                return null;
            }
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(apiUrl + "/b2api/v1/b2_list_file_versions");
            string body = "{\"bucketId\":\"" + bucketId + "\","
                + "\"startFileName\":\"" + startFileName + "\"}";
            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();
            }
            try
            {
                HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
                var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                B2FileList fileList = (B2FileList)Newtonsoft.Json.JsonConvert.DeserializeObject(responseString, typeof(B2FileList));
                return fileList;
            }
            catch (Exception ex)
            {
                return null;
            };
        }
public B2FileList b2_list_file_versions ( string bucketId , string startFileName ) { if ( ! checkStringParamsNotEmpty ( new string [ ] { bucketId } ) || ! authorized ) { return null ; } HttpWebRequest webRequest = ( HttpWebRequest ) WebRequest . Create ( apiUrl + " " ) ; string body = " \" \" \" " + bucketId + " \" " + " \" \" \" " + startFileName + " \" " ; 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 ( ) ; } try { HttpWebResponse response = ( HttpWebResponse ) webRequest . GetResponse ( ) ; var responseString = new StreamReader ( response . GetResponseStream ( ) ) . ReadToEnd ( ) ; B2FileList fileList = ( B2FileList ) Newtonsoft . Json . JsonConvert . DeserializeObject ( responseString , typeof ( B2FileList ) ) ; return fileList ; } catch ( Exception ex ) { return null ; } ; }
Gets versions of every file in a bucket starting with the start file name
Gets versions of every file in a bucket starting with the start file name
- list of files in bucket
- list of files in bucket
bucketId
string
id of bucket to search
id of bucket to search
startFileName
string
starting file name for files
starting file name for files