0

I haven't wrote any server side code till now. Is there any way I can try writing an android program where I can write the file being uploaded from the mobile to a remote server?

Additional details:- My code -

private void sendToRemoteServer(){
         Socket client;
         FileInputStream fileInputStream;
         BufferedInputStream bufferedInputStream;
         OutputStream outputStream;

         try{
             client                 =   new Socket("10.0.2.2",444);
             byte[] myByteArray     =   new byte[(int)mFile.length()];
             fileInputStream        =   new FileInputStream(mFile);
             bufferedInputStream    =   new BufferedInputStream(fileInputStream);

             bufferedInputStream.read(myByteArray, 0, myByteArray.length); //read the file

             outputStream = client.getOutputStream();

             outputStream.write(myByteArray, 0, myByteArray.length); //write file to the output stream byte by byte
             outputStream.flush();
             bufferedInputStream.close();
             outputStream.close();
             client.close();
         }catch(UnknownHostException e) {
             e.printStackTrace();
            } catch (IOException e) {
             e.printStackTrace();
            }
    }

All I need to make sure is that android doesn't run out of memory exception.

4

2 に答える 2

2

いくつかのオプションがあります。1 つは、サーバーで webDAV または FTP を使用することです。しかし最近では、Amazon S3 のような RESTful API でアクセスできるファイル ストレージ サービスがたくさんあります。

于 2013-06-14T11:24:26.443 に答える
0

サーバーをモックしたいようです。https://stackoverflow.com/questions/393099/mocking-http-serverは、出発点として適しています。

于 2013-06-14T11:29:25.630 に答える