1

Android デバイスから Drupal Web サイトに画像をアップロードしようとしました

Drupal 側でメソッド file.create を使用して Service モジュールを使用しました。

問題は、ダウンロード後にファイルが壊れていることです。

ファイルは小さくなります。

filemime 設定には効果がありません。

ジャバサイド:

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

1 に答える 1