繁体   English   中英

在 java/Android 中使用 HTTP PUT 创建文件时没有文件创建/修改日期

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

我正在为 android 开发一个应用程序,该应用程序使用 HTTP PUT 读取/写入无线设备。

有没有办法设置由 HTTP PUT 创建的文件的创建/修改日期和时间属性,因为目前文件创建良好但没有属性(创建日期时间,修改日期时间。

如果您需要一些代码片段,请告诉我。(不确定有什么帮助)

这可能是设备的后备,即设备负责将这些属性添加到文件中吗?

我试过在网上搜索,但这个问题很难用 1 行/几句话来解释:)

提前致谢。

编辑:为了澄清,我试图写的文件已经存在,所以 HTTP PUT 只是覆盖它。(简单的文本文件)。 所以我只是传递一个 BYTEARRAY 实体来写入这个文件。 但不知何故,在这个过程中,文件属性正在丢失。

编辑:以下是 uploadFile 代码片段。 私人无效上传文件(字符串数据){

   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();
    }
}

file.setLastModified(long)有什么问题?

一些旧报告称它不起作用但似乎已修复。

我找不到有关设置创建日期的任何信息,因为创建日期应在自动创建文件时设置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM