【发布时间】:2011-07-22 01:23:59
【问题描述】:
我正在开发一个使用 HTTP PUT 读取/写入无线设备的 Android 应用程序。
有没有办法设置由 HTTP PUT 创建的文件的创建/修改日期和时间属性,因为目前文件创建良好但没有属性(创建日期时间、修改日期时间。
如果您需要一些代码 sn-p,请告诉我。(不确定有什么帮助)
这可能是设备的后备,即设备负责将这些属性添加到文件中吗?
我试过在网上搜索,但这个问题很难用 1 行/几句话来解释:)
提前致谢。
编辑:澄清一下,我尝试编写的文件已经存在,所以 HTTP PUT 只是简单地覆盖它。(简单文本文件)。所以我只是传递一个 BYTEARRAY 实体来写入这个文件。但不知何故,在这个过程中,文件属性丢失了。
编辑:以下是uploadFile代码sn-p。 私人无效上传文件(字符串数据){
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();
}
}
【问题讨论】:
标签: android file http attributes put