AndroidAsync
AndroidAsync copied to clipboard
SendFile Failed
Hi, I tried the following code in the main activity:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
final File videoFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Download/mv.mp4");
AsyncHttpServer server = new AsyncHttpServer();
List<WebSocket> _sockets = new ArrayList<WebSocket>();
server.get("/", new HttpServerRequestCallback() {
@Override
public void onRequest(AsyncHttpServerRequest request, AsyncHttpServerResponse response)
{
long fileSize = videoFile.length();
System.out.println("File Size: " + fileSize);
response.sendFile(videoFile);
}
});
server.listen(5000);
}
When I input http://10.0.0.234:5000/, I only get "File Size in Server: 63018711".
However, the browser shows "This 10.0.0.234 page can’t be found No webpage was found for the web address: http://10.0.0.234:5000/ Search Google for 234 5000 HTTP ERROR 404"
Can you help me with that? Thanks a lot!
we have same question
I add ActivityCompat.requestPermissions(Main2Activity.this, PERMISSIONS_STORAGE, 1); to solved