【问题标题】:Upload a file from Android to Drupal via Services Module通过服务模块将文件从 Android 上传到 Drupal
【发布时间】: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


【解决方案1】:

好吧,如果您的 Drupal 站点没有使用原生 android 应用程序,则不需要任何其他“接口”来上传文件!它应该像从桌面上传文件一样工作!

【讨论】:

    猜你喜欢
    • 2016-10-22
    • 1970-01-01
    • 2016-09-26
    • 1970-01-01
    • 2012-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-04
    相关资源
    最近更新 更多