FileSync/FileSync/B2SDK.cs
/// <summary>
/// Returns file info in string form for a given fileId
/// </summary>
/// <param name="fileId"> string file id </param>
/// <returns> B2FileInfo object of file information</returns>
Returns file info in string form for a given fileId
Returns file info in string form for a given fileId
public B2FileInfo b2_get_file_info(string fileId)
        {
            if (!checkStringParamsNotEmpty(new string[] { fileId }) || !authorized)
            {
                return null;
            }
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(apiUrl + "/b2api/v1/b2_get_file_info");
            string body = "{\"fileId\":\"" + fileId + "\"}";
            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();
                B2FileInfo fileInfo = (B2FileInfo)Newtonsoft.Json.JsonConvert.DeserializeObject(responseString, typeof(B2FileInfo));
                return fileInfo;
            }
            catch (Exception ex)
            {
                return null;
            };
        }
public B2FileInfo b2_get_file_info ( string fileId ) { if ( ! checkStringParamsNotEmpty ( new string [ ] { fileId } ) || ! authorized ) { return null ; } HttpWebRequest webRequest = ( HttpWebRequest ) WebRequest . Create ( apiUrl + " " ) ; string body = " \" \" \" " + fileId + " \" " ; 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 ( ) ; B2FileInfo fileInfo = ( B2FileInfo ) Newtonsoft . Json . JsonConvert . DeserializeObject ( responseString , typeof ( B2FileInfo ) ) ; return fileInfo ; } catch ( Exception ex ) { return null ; } ; }
Returns file info in string form for a given fileId
Returns file info in string form for a given fileId
B2FileInfo object of file information
B2FileInfo object of file information
fileId
string
string file id
string file id