Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5
    • Fix Version/s: 2.6
    • Component/s: Web Services
    • Testing Instructions:
      Hide

      Setup

      1. Testing requires database and code changes
      2. Run unit tests and make sure they all pass
      3. Setup webservices for the api core_files_upload()
        http://docs.moodle.org/25/en/Using_web_services
      4. In the above setup make sure the user you are going to use for making ws calls is admin or as all the permissions required to upload files to private area
      5. Get your fav client from https://github.com/moodlehq/sample-ws-clients or use the one I use https://github.com/ankitagarwal/moodle-ws-client/blob/master/client.php
      6. Note the format of params to use for your upload() api , based on your client protocol from (moodle/admin/webservice/documentation.php )

      Test - 1 - Using context ids

      1. Get context for a user using

        Print_object(context_user::instance($user->id);)
        

      2. Now call the api upload with parameters like

                $contextid = $context->id;
                $component = "user";
                $filearea = "private";
                $itemid = 0;
                $filepath = "/";
                $filename = "Simple.txt";
                $filecontent = base64_encode("Let us create a nice simple file");
        

      3. Make sure you can see and download the file from the user's private files area

      Test 2 - Without context id

      1. Now call the api upload with parameters like

                $contextid = 0;
                $component = "user";
                $filearea = "private";
                $itemid = 0;
                $filepath = "/";
                $filename = "Simple2.txt";
                $filecontent = base64_encode("Let us create a nice simple file");
                $contextlevel = "user";
                $instanceid = $userid;
        
        

      2. Make sure you can see and download the file from the user's private files area

      Test 3 - Exception testing

      1. Now call the api again with
      2. Now call the api upload with parameters like

                $contextid = 0;
                $component = "user";
                $filearea = "private";
                $itemid = 0;
                $filepath = "/";
                $filename = "Simple2.txt";
                $filecontent = base64_encode("Let us create a nice simple file");
        
        

      3. Make sure you see a missing parameters error.
      Show
      Setup Testing requires database and code changes Run unit tests and make sure they all pass Setup webservices for the api core_files_upload() http://docs.moodle.org/25/en/Using_web_services In the above setup make sure the user you are going to use for making ws calls is admin or as all the permissions required to upload files to private area Get your fav client from https://github.com/moodlehq/sample-ws-clients or use the one I use https://github.com/ankitagarwal/moodle-ws-client/blob/master/client.php Note the format of params to use for your upload() api , based on your client protocol from (moodle/admin/webservice/documentation.php ) Test - 1 - Using context ids Get context for a user using Print_object(context_user::instance($user->id);) Now call the api upload with parameters like $contextid = $context->id; $component = "user"; $filearea = "private"; $itemid = 0; $filepath = "/"; $filename = "Simple.txt"; $filecontent = base64_encode("Let us create a nice simple file"); Make sure you can see and download the file from the user's private files area Test 2 - Without context id Now call the api upload with parameters like $contextid = 0; $component = "user"; $filearea = "private"; $itemid = 0; $filepath = "/"; $filename = "Simple2.txt"; $filecontent = base64_encode("Let us create a nice simple file"); $contextlevel = "user"; $instanceid = $userid; Make sure you can see and download the file from the user's private files area Test 3 - Exception testing Now call the api again with Now call the api upload with parameters like $contextid = 0; $component = "user"; $filearea = "private"; $itemid = 0; $filepath = "/"; $filename = "Simple2.txt"; $filecontent = base64_encode("Let us create a nice simple file"); Make sure you see a missing parameters error.
    • Affected Branches:
      MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE
    • Pull Master Branch:
      MDL-40039-master
    • Story Points:
      5
    • Sprint:
      BACKEND Sprint 3

      Description

      Add alternative to contextid for core_files_external::upload, contextid shouldn't be a required field as per the discussion on MDL-40037

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  18/Nov/13