Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-70387

New Web Service core_files_get_unused_draft_itemid

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.10
    • Fix Version/s: 3.11
    • Component/s: Files API
    • Labels:
    • Testing Instructions:
      Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create a Token in the mobile app service for any user in the site (not an admin account)
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      3. Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours.

        curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_files_get_unused_draft_itemid&wstoken=WSTOKEN' | python -m "json.tool"

      4. Confirm that:
        • The value for the component field is user
        • The value for the filearea field is draft
        • The value for the userid field is the user making the request id
      5. Copy somewhere the returned itemid
      6. Execute the following curl request pointing to a file in your local system (it will upload a file) you will have to replace the LOCAL_PATH_TO_FILE, ITEMID and WSTOKEN values apart from the SITEURL:

        curl -i -F name=filename.ext -F filedata=@/LOCAL_PATH_TO_FILE/filename.ext "SITEURL/webservice/upload.php?token=WSTOKEN&filearea=draft&itemid=ITEMID"

      7. Confirm that:
        • As the request response, you see a json
        • The contextid, component, filearea and itemid values matches the ones from the initial request

       
       

      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for any user in the site (not an admin account) Click on Site administration ► Plugins ► Web services ► Manage tokens Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours. curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_files_get_unused_draft_itemid&wstoken=WSTOKEN' | python -m "json.tool" Confirm that: The value for the component field is user The value for the filearea field is draft The value for the userid field is the user making the request id Copy somewhere the returned itemid Execute the following curl request pointing to a file in your local system (it will upload a file) you will have to replace the LOCAL_PATH_TO_FILE, ITEMID and WSTOKEN values apart from the SITEURL: curl -i -F name=filename.ext -F filedata=@/LOCAL_PATH_TO_FILE/filename.ext "SITEURL/webservice/upload.php?token=WSTOKEN&filearea=draft&itemid=ITEMID" Confirm that: As the request response, you see a json The contextid, component, filearea and itemid values matches the ones from the initial request    
    • Affected Branches:
      MOODLE_310_STABLE
    • Fixed Branches:
      MOODLE_311_STABLE
    • Pull from Repository:
    • Pull 3.11 Branch:
      MDL-70387-311
    • Pull Master Branch:
      MDL-70387-master

      Description

      New WS for retrieving an unused draft item id for external systems.

      To be used when we need to manipulate/create temporary draft file areas from external systems (see MDL-69952 for a user case)

        Attachments

          Activity

            People

            Assignee:
            jleyva Juan Leyva
            Reporter:
            jleyva Juan Leyva
            Peer reviewer:
            Pau Ferrer
            Integrator:
            Sara Arjona (@sarjona)
            Tester:
            Anna Carissa Sadia
            Participants:
            Component watchers:
            Matteo Scaramuccia, Andrew Nicols, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              10/May/21

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 10 minutes
                3h 10m