开发者

No file creation/modified date when a file created using HTTP PUT in java/Android

I am developing an app for android that reads/write to a wireless device using HTTP PUT.

Is there a way to set the creation/modified date &am开发者_Go百科p; time attribute of a file being created by HTTP PUT because at the moment the file is created fine but with no attributes (creation datetime, modified datetime.

Let me know if you need some code snippet.(not sure what will help)

Could this be a fallback of the device i.e. the device is responsible for adding these attributes to a file?

I have tried searching the net but this problem is hard to explain in 1 line/few words :)

Thanks in advance.

Edit: Just to clarify, the file that I am trying to write already exists so HTTP PUT is simply overriding it.(simple text file). and So I just pass a BYTEARRAY entity to be written to this file. But somehow in this process, the file attributes are getting lost.

Edit: Following is the uploadFile code snippet. private void uploadFile(String data){

   try{
          HttpClient http = new DefaultHttpClient(); //declare and initialize the HTTP client.
          //Using HTTP PUT, upload the data to the Settings file
          HttpPut putmethod = new HttpPut("http://airstash.net/files/SETTINGS.TXT"); 
          putmethod.setEntity(new ByteArrayEntity(data.getBytes("iso-8859-1")));
          putmethod.setHeader("Content_Type", "Text/Plain");
          HttpResponse response = http.execute(putmethod); //Execute the PUT request and receive response.
          if(response!= null)
          {
   //Show the response code (for testing only)
        String responsecode = Integer.toString(response.getStatusLine().getStatusCode());
        Toast.makeText(getApplicationContext(), responsecode, Toast.LENGTH_LONG).show();
    }
   }
    catch(Exception e){
        e.printStackTrace();
    }
}


What's wrong with file.setLastModified(long)?

Some old reports that it doesn't work but appears to be fixed.

I can't find any information on setting the creation date because the creation date should be set when the file was created automatically.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜