如何使用 java sdk 将资产上传到 usergrid api

How to upload an asset to usergrid api using java sdk

我是 api 的新手,尤其是用户网格。但是我必须通过代码(Java)测试 usergrid。有人 post 可以使用 java 客户端将资产(文件)上传到 usergrid 的方法吗?

经过一番努力后,我发现 way.Here 它是..

    public static ApiResponse uploadFileToServer(){
    File file = new File("your asset path");
    Map<String, Object> dataParams = new HashMap<String, Object>();
    data.put("name", <file_name>);
    data.put("file", file);
    //here type and name are necessary to create entity
    data.put("type", <collection_name>);
    data.put("name", <entity_name>);
    //entity_name will be the name of your new created entity.
    Client client = new Client(<organization_name>, <application_name>);
    client.setApiUrl(<url to hit>);
    client.authorizeAppUser(<username>, <password>);
    client.createEntity(dataParams);
    String <uri> = <collection_name> + "/" + <entity_name>;
    ApiResponse response = client.httpRequest(HttpMethod.POST,ApiResponse.class, null, dataParams, <organization_name>, <application_name>,
            <uri>);
    return response;
    }