I want send my android .apk file to my client(browser) from java restful web service.I try to use bellow code. But it produce a file named "MyPath" without any file extension (require .apk).Thanks in advance
@Path("MyPath")
public class MyPathResource {
@Context
private UriInfo context;
/**
* Creates a new instance of MyPathResource
*/
public MyPathResource() {
}
@GET
@Produces("application/vnd.android.package-archive")
public File getFile() {
// return my file
return new File("E:\\CommandLineAndroidProjet1\\bin\\FirstCommandLineApp-release.apk");
}
}
Try creating an explicit javax.ws.core.Response
:
return Response.status(Response.Status.OK)
.entity(entity)
.header("Content-Disposition", "attachment; filename=" + fileName)
.build();
while entity
is your file as byte array and fileName
is the file name with .apk
suffix.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.