拒绝访问用户匿名将图像从android应用程序上载到drupal

拒绝访问用户匿名将图像从android应用程序上载到drupal,android,image,upload,drupal-7,Android,Image,Upload,Drupal 7,我可以成功登录并检索session\u name和session\u id,但当我执行上载任务时,响应被拒绝访问。我已经确定了权限。我正在发送uid、文件名和编码文件。我很沮丧,请帮忙 HttpClient httpclient = new DefaultHttpClient(); try { //set the remote endpoint URL HttpPost httppost = new HttpPost("ht

我可以成功登录并检索
session\u name
session\u id
,但当我执行上载任务时,响应被拒绝访问。我已经确定了权限。我正在发送uid、文件名和编码文件。我很沮丧,请帮忙

   HttpClient httpclient = new DefaultHttpClient();
        try {

            //set the remote endpoint URL
            HttpPost httppost = new HttpPost("http://drupal/androidrpc-endpoint/user/login");
            if (resultSet.moveToFirst()) {
                //if database is not empty
                resultSet.moveToFirst();
                String username = resultSet.getString(1);//get the username saved in the database
                String password = resultSet.getString(2);//get the password saved in the database
                try {
                    JSONObject json = new JSONObject();
                    //extract the username and password from UI elements and create a JSON object
                    json.put("username", username);
                    json.put("password", password);
                    //add serialised JSON object into POST request
                    StringEntity se = new StringEntity(json.toString());
                    //set request content type
                    se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
                    httppost.setEntity(se);
                    //send the POST request
                    HttpResponse response = httpclient.execute(httppost);
                    //read the response from Services endpoint
                    String jsonResponse = EntityUtils.toString(response.getEntity());
                    System.out.println("The response from log in is "+ jsonResponse);//here the response is correct
                    JSONObject jsonObject = new JSONObject(jsonResponse);
                    //read the session information
                    session_name = jsonObject.getString("session_name");
                    session_id = jsonObject.getString("sessid");

                    log_in = true;
                } catch (Exception e) {
                    log_in = false;
                    e.printStackTrace();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        database.close();
        String URI = "http://10.0.0.14/drupal/androidrpc-endpoint/file";
        String filePath = "mnt/sdcard/application/android.png";
        Bitmap bm = BitmapFactory.decodeFile(filePath);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bm.compress(Bitmap.CompressFormat.JPEG, 100, baos);
        byte[] byteArrayImage = baos.toByteArray();
        BasicHttpContext localContext = new BasicHttpContext();
        CookieStore mCookieStore = new BasicCookieStore();

        try {
            JSONObject fileObject = new JSONObject();


            HttpClient mHttpClient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost(URI);
            httppost.setHeader(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));

            fileObject.put("file", Base64.encodeToString(byteArrayImage, Base64.DEFAULT));
            fileObject.put("filename", "android.PNG");
            fileObject.put("uid", 1);
            StringEntity se = new StringEntity(fileObject.toString());
            httppost.setEntity(se);
            BasicClientCookie coo = new BasicClientCookie(session_name, session_id);
            coo.setVersion(0);
            coo.setDomain("10.0.0.14/drupal/");
            coo.setPath("/");
            mCookieStore.addCookie(coo);
            coo = new BasicClientCookie("has_js", "1");
            mCookieStore.addCookie(coo);
            localContext.setAttribute(ClientContext.COOKIE_STORE, mCookieStore);
            HttpResponse response = mHttpClient.execute(httppost,localContext);
            String logResponse = EntityUtils.toString(response.getEntity());
            System.out.println("Uploading response"+ logResponse);


        } catch (Exception e) {
            e.printStackTrace();
        }

用户1可以访问Drupal上的所有内容。不知怎的,当你上传文件时,Drupal没有认出你是用户1。这就是你的问题所在,但我没有解决的办法:(无论如何,非常感谢)D很抱歉迟了回复,我本来希望有人会回复的。