is it possible to upload file using openbullet



  • for example i want to upload file to a website nammed xyz for the equilant code in c# is

    class Program
        {
            static void Main(string[] args) {
    
                // HttpClient is normally created once, then used for all message sending
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri("https://xyz.com/v2/");
                client.DefaultRequestHeaders.Add("authorization", "YOUR-API-TOKEN");
    
                string jsonResult = SendFile(client, @"/path/to/foo.wav").Result;
                System.Console.WriteLine(jsonResult);
            }
    
    
            private static async Task SendFile(HttpClient client, string filePath) {
                try {
                    HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "upload");
                    request.Headers.Add("Transer-Encoding", "chunked");
    
                    var fileReader = System.IO.File.OpenRead(filePath);
                    var streamContent = new StreamContent(fileReader);
                    request.Content = streamContent;
    
                    HttpResponseMessage response = await client.SendAsync(request);
                    return await response.Content.ReadAsStringAsync();
                }
                catch (Exception ex) {
                    System.Console.WriteLine($"Exception: {ex.Message}");
                    throw;
                }
            }
    
        }
    
    }
    

    can we do this using request block in openbullet


  • Admin

    You have to use the raw content type, read all bytes from the file (as HEX) and send those.



  • @Ruri thanks. for getting hex data of file we will use this ?

    UTILITY File "foo.wav" Read -> VAR "data" 
    
    UTILITY Conversion ASCII HEX "<data>" -> VAR "hex data"
    

Log in to reply