خرید بک لینک

Vote count: 0

So I got this gradle script that let's me upload apks to Nexus. The issue is that those files end up without file extension on the server which is a problem if you want to download an app from there.

It seems that I'm passing the proper mime type but even with that I'm still getting a file without extension.

Here is the code:

def uploadToRepository(File file, 
    String folder, 
    String url, 
    String userName, 
    String password){

    HTTPBuilder http = new HTTPBuilder(url)
    String basicAuthString = "Basic " + "${userName}:${password}".bytes.encodeBase64().toString()

    http.client.addRequestInterceptor(new HttpRequestInterceptor() {
        void process(HttpRequest httpRequest, HttpContext httpContext) {
            httpRequest.addHeader('Authorization', basicAuthString)
        }
    })
    try {
        http.request(Method.POST, "application/vnd.android.package-archive") { req ->
            uri.path = "/content/repositories/releases/${folder}"

            MultipartEntity entity = new MultipartEntity()
            def fileBody = new FileBody(file, "application/vnd.android.package-archive")
            entity.addPart("file", fileBody)
            req.entity = entity

            response.success = { resp, reader ->
                if(resp.status == 201) {
                    println "File ${file.name} uploaded"
                }
            }
        }

    } catch (Exception e) {
        e.printStackTrace()
    }
}

asked 48 secs ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 12 ارديبهشت 1395 ساعت: 18:57

صفحه بندی