FileSync/FileSync/B2SDK.cs
/// <summary>
/// Hides a file by its name. It will still exist and can be downloaded by version.
/// </summary>
/// <param name="bucketId"> Id of the bucket</param>
/// <param name="fileName"> Id of the file</param>
/// <returns> Bool True if successful, false if any error</returns>
Hides a file by its name. It will still exist and can be downloaded by version.
Hides a file by its name . It will still exist and can be downloaded by version .
public bool b2_hide_file(string bucketId, string fileName)
        {
            if (!checkStringParamsNotEmpty(new string[] { fileName, bucketId }) || !authorized)
            {
                return false;
            }
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(apiUrl + "/b2api/v1/b2_hide_file");
            string body =
            "{\"bucketId\":\"" + bucketId + "\",\n" +
            "\"fileName\":\"" + fileName + "\"}";
            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();
            }
            HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
            if (response.StatusCode == HttpStatusCode.OK)
            {
                response.Close();
                return true;
            }
            else
            {
                response.Close();
                return false;
            }
        }
public bool b2_hide_file ( string bucketId , string fileName ) { if ( ! checkStringParamsNotEmpty ( new string [ ] { fileName , bucketId } ) || ! authorized ) { return false ; } HttpWebRequest webRequest = ( HttpWebRequest ) WebRequest . Create ( apiUrl + " " ) ; string body = " \" \" \" " + bucketId + " \" \n " + " \" \" \" " + fileName + " \" " ; 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 ( ) ; } HttpWebResponse response = ( HttpWebResponse ) webRequest . GetResponse ( ) ; if ( response . StatusCode == HttpStatusCode . OK ) { response . Close ( ) ; return true ; } else { response . Close ( ) ; return false ; } }
Hides a file by its name.
Hides a file by its name .
Bool True if successful, false if any error
Bool True if successful false if any error
bucketId
string
Id of the bucket
Id of the bucket
fileName
string
Id of the file
Id of the file