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

New Web Service core_files_delete_draft_files

    XMLWordPrintable

Details

    • MOODLE_39_STABLE
    • MOODLE_310_STABLE
    • MDL-69776-master
    • Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create or use an existing non-admin user account in the site
      3. Create a Token in the mobile app service for the previous user in the site
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      4. Log-in into the site with the user account
      5. Go to the "Private files" section via the left menu
      6. Now create the following directories and files:
        • One file named txtfile0.txt
        • One file named imgfile.png (or jpg, any image)
        • One directory named directory1
        • One txt file inside the "directory1" named txtfile1.txt
      7. DO NOT "Save changes" you should leave the "Private files" page open in the browser
      8. Now, extract the draftitemid from the page, for that you can "View the source code" of the page and look for the following link with this string inside: repository/draftfiles_manager.php
      9. You will see that the link contains an itemid parameter, copy the value because you will use it later
      10. Open the console an execute this new curl request, replacing wstoken with the token you just created, the site url with yours and DRAFTITEMID with the itemid value you copied in the previous step.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_files_delete_draft_files&wstoken=3af67232a7596ceb658df4db329e5ad6&draftitemid=DRAFTITEMID&files[0][filepath]=/directory1/&files[0][filename]=&files[1][filepath]=/&files[1][filename]=txtfile0.txt' | python -m "json.tool"

      11. Go back to the "Private files" page
      12. Click on the "Files" link that is on top of the files thumbnails and bellow the icons for adding files and creating directory, this will reload the file manager and confirm that
        • You only see the imgfile.png file, the rest of the files and directories are gone
      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create or use an existing non-admin user account in the site Create a Token in the mobile app service for the previous user in the site Click on Site administration ► Plugins ► Web services ► Manage tokens Log-in into the site with the user account Go to the "Private files" section via the left menu Now create the following directories and files: One file named txtfile0.txt One file named imgfile.png (or jpg, any image) One directory named directory1 One txt file inside the "directory1" named txtfile1.txt DO NOT "Save changes" you should leave the "Private files" page open in the browser Now, extract the draftitemid from the page, for that you can "View the source code" of the page and look for the following link with this string inside: repository/draftfiles_manager.php You will see that the link contains an itemid parameter, copy the value because you will use it later Open the console an execute this new curl request, replacing wstoken with the token you just created, the site url with yours and DRAFTITEMID with the itemid value you copied in the previous step. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_files_delete_draft_files&wstoken=3af67232a7596ceb658df4db329e5ad6&draftitemid=DRAFTITEMID&files [0] [filepath] =/directory1/&files [0] [filename] =&files [1] [filepath] =/&files [1] [filename] =txtfile0.txt' | python -m "json.tool" Go back to the "Private files" page Click on the "Files" link that is on top of the files thumbnails and bellow the icons for adding files and creating directory, this will reload the file manager and confirm that You only see the imgfile.png file, the rest of the files and directories are gone

    Description

      Web Service for deleting files in a temporary user draft file area.

      This is a WebService that could be used to delete draft files from external systems (like the Moodle app).

      A typical use case will be for example deleting the attachments of a quiz essay question (during the attempt) or deleting images from an html editor.

      Attachments

        Issue Links

          Activity

            People

              jleyva Juan Leyva
              jleyva Juan Leyva
              Pau Ferrer Pau Ferrer
              Andrew Lyons Andrew Lyons
              Gladys Basiana Gladys Basiana
              Matteo Scaramuccia, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo, Juan Leyva, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                9/Nov/20

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours, 30 minutes
                  4h 30m