Java 是否从RESTWeb服务向客户端发送.apk文件?
我想从JavaRESTfulWeb服务将我的android.apk文件发送到我的客户端(浏览器)。但是它会生成一个名为“MyPath”的文件,没有任何文件扩展名(require.apk)。请提前感谢Java 是否从RESTWeb服务向客户端发送.apk文件?,java,android,rest,Java,Android,Rest,我想从JavaRESTfulWeb服务将我的android.apk文件发送到我的客户端(浏览器)。但是它会生成一个名为“MyPath”的文件,没有任何文件扩展名(require.apk)。请提前感谢 @Path("MyPath") public class MyPathResource { @Context private UriInfo context; /** * Creates a new instance of MyPathResource
@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");
}
}
尝试创建一个显式的
javax.ws.core.Response
:
return Response.status(Response.Status.OK)
.entity(entity)
.header("Content-Disposition", "attachment; filename=" + fileName)
.build();
而实体
是作为字节数组的文件,而文件名
是带有.apk
后缀的文件名