question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why files are sand and saved in format .bin ?

See original GitHub issue

Good day! Rewrote the script from Python to Groovy, send reports to the server, but attachments do not appear, if you upload them they are in .bin format. Tell me the pictures do not need to be encrypted when sending? image image

task sendReports {
    group "Work Allure Server api"
    description "send results test in remote server"
    doLast {
        File f = new File("${project.buildDir}/allure-results");
        if (f.exists() && f.isDirectory()) {
            def request = new Request()
            f.eachFile {
                Reports files = new Reports(
                        file_name: it.name,
                        content_base64: it.text.bytes.encodeBase64()
                )
                request.results.add(files)
            }
            def req = new URL(gradle.allureServer+"/send-results").openConnection()
            req.setRequestMethod("POST")
            req.setRequestProperty("Content-Type", "application/json; charset=UTF-8")
            req.setDoOutput(true)
            req.getOutputStream().write(JsonOutput.toJson(request).getBytes("UTF-8"))
            logger.quiet "Status code: ${req.getResponseCode()}"
            def resp = new JsonSlurper().parseText(req.getInputStream().getText())
            logger.quiet "Response: ${resp}"
        } else {
            logger.quiet "Not folder: ${project.buildDir}/allure-results"
        }
    }
}

class Request {
    List<Reports> results = new LinkedList<>()
}
class Reports {
    String file_name
    String content_base64
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fescobarcommented, Mar 31, 2020
1reaction
FullZero5commented, Mar 24, 2020

I’ll add the code, it might come in handy for someone (it works somehow)

task sendReports {
    group "Work Allure Server api"
    description "send results test in remote server"
    doLast {
        File f = new File("${project.buildDir}/allure-results")
        if (f.exists() && f.isDirectory()) {
            def request = new Request()
            f.eachFile {
                Reports files = new Reports(
                        file_name: it.name,
                        content_base64: it.bytes.encodeBase64()
                )
                request.results.add(files)
            }
            def req = new URL(gradle.allureServer+"/send-results").openConnection()
            req.setRequestMethod("POST")
            req.setRequestProperty("Content-Type", "application/json; charset=UTF-8")
            req.setDoOutput(true)
            req.getOutputStream().write(JsonOutput.toJson(request).getBytes("UTF-8"))
            logger.quiet "Status code: ${req.getResponseCode()}"
            def resp = new JsonSlurper().parseText(req.getInputStream().getText())
            logger.quiet "Response: ${resp}"
        } else {
            logger.quiet "Not folder: ${project.buildDir}/allure-results"
        }
    }
}

class Request {
    List<Reports> results = new LinkedList<>()
}
class Reports {
    String file_name
    String content_base64
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Open BIN Files | .BIN File Opener Tools
BIN files that are saved in the basic binary format. But for others, you can't open them directly on your computer. You can...
Read more >
Attachments coming through as bin files - TechNet - Microsoft
The file shows as bin even when accessed through OWA, directly on Exchange. Any idea what's going on?
Read more >
How to Open a Bin File on Android
The .BIN file format is actually designed to store information in a binary format. The binary formatting is compatible with disk storage and...
Read more >
Decoding Binary File Formats - YouTube
A basic introduction to processing binary files in Ruby, using PNG as an example. Code is at: https://github.com/sandal/binary_examples.
Read more >
How to view a binary file? - Unix & Linux Stack Exchange
Compiled binary files are no different, they are stored as 1's and 0's. arzyfex's answer gives you the tools to view those files...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found