【发布时间】:2012-11-14 23:19:59
【问题描述】:
我尝试将图像从 Android 设备上传到 Drupal 网站
我在 Drupal 端使用了 Service 模块和方法 file.create。
问题是下载后文件已损坏。
文件更小。
filemime 设置有 n 效果。
Javaside:
public Map saveFile(String localFilePath, String serverpath) throws XmlRpcException, IOException{
HashMap<String, Object> account = new HashMap<String, Object>();
File localFile = new File(localFilePath);
Log.w("XMLRPC", "FILENAME "+localFile.getName() + " original "+localFile.length());
String fileAsString = readFile(localFilePath);
// Sending side
byte[] data = fileAsString.getBytes("UTF-8");
byte[] base64 = Base64.encode(data,Base64.URL_SAFE);
account.put("file", base64);
account.put("filename", localFile.getName());
account.put("filepath", serverpath +"/"+ localFile.getName());
// account.put("filemime", "application/x-compressed");
account.put("filesize", Integer.parseInt(localFile.length()+""));//String.valueOf(localFile.length()));
Vector<Object> params = new Vector<Object>();
params.add(account);
return (Map) xmlRpcClient.execute(METHOD_FILE_CREATE, params);
}
【问题讨论】:
-
filemime 确实没有任何作用,因为它在服务器端的 file.create 处理程序中被替换了。
标签: android drupal service upload