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

New Web Service core_files_delete_draft_files

    XMLWordPrintable

    Details

    • Affected Branches:
      MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_310_STABLE
    • Pull from Repository:
    • Pull 3.10 Branch:
      MDL-69776-310
    • Pull Master Branch:
      MDL-69776-master
    • Testing Instructions:
      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

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Pau Ferrer Pau Ferrer
              Integrator:
              Andrew Lyons Andrew Lyons
              Tester:
              Gladys Basiana Gladys Basiana
              Participants:
              Component watchers:
              Matteo Scaramuccia, Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                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