Skip to content

Commit

Permalink
post file if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
importre committed Apr 17, 2015
1 parent 916f174 commit 103147f
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions src/main/groovy/co/riiid/gradle/ReleaseTask.groovy
Expand Up @@ -63,29 +63,31 @@ class ReleaseTask extends DefaultTask {
def http = new HttpBuilder(host)
def file = new File(asset as String)

def map = URLConnection.getFileNameMap()
def contentType = map.getContentTypeFor(asset as String)

http.ignoreSSLIssues()
http.request(Method.POST) { req ->
uri.path = path
uri.query = [
name: name,
]
send ContentType.BINARY, file.bytes

headers.'User-Agent' = HEADER_USER_AGENT
headers.'Authorization' = "token ${project.github.token}"
headers.'Accept' = HEADER_ACCEPT
headers.'Content-Type' = contentType


response.success = { resp, json ->
println json
}

response.failure = { resp, json ->
System.err.println json
if (file.exists()) {
def map = URLConnection.getFileNameMap()
def contentType = map.getContentTypeFor(asset as String)

http.ignoreSSLIssues()
http.request(Method.POST) { req ->
uri.path = path
uri.query = [
name: name,
]
send ContentType.BINARY, file.bytes

headers.'User-Agent' = HEADER_USER_AGENT
headers.'Authorization' = "token ${project.github.token}"
headers.'Accept' = HEADER_ACCEPT
headers.'Content-Type' = contentType


response.success = { resp, json ->
println json
}

response.failure = { resp, json ->
System.err.println json
}
}
}
}
Expand Down

0 comments on commit 103147f

Please sign in to comment.