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

Design way to send files by web service (upload)

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.6
    • Component/s: Hub
    • Testing Instructions:
      Hide

      (Requires curl)

      1. Create a webservice with "Can upload files" enabled.
      2. Create a webservice token for a user
      3. Create a test file:

        echo "Actually vegemite on croissants is quite nice" > upload.txt
        

      4. Test uploading the file (replace the token and url with your own):

        curl -F token=927784a730aba681d84bbf6c13e1d3da -F filearea=draft -F file=@upload.txt -v http://damyon.moodle.local/im/webservice/upload.php
        

      Check for a valid json response with a generated item id.
      e.g.

      [

      {"component":"user","contextid":"28","userid":"16","filearea":"draft","filename":"upload.txt","filepath":"\/","itemid":955505089,"license":"allrightsreserved","author":"Officer Barbady","source":""}

      ]

      Run unit tests:
      ./vendor/bin/phpunit webservice/tests/externallib_test.php

      Show
      (Requires curl) Create a webservice with "Can upload files" enabled. Create a webservice token for a user Create a test file: echo "Actually vegemite on croissants is quite nice" > upload.txt Test uploading the file (replace the token and url with your own): curl -F token=927784a730aba681d84bbf6c13e1d3da -F filearea=draft -F file=@upload.txt -v http://damyon.moodle.local/im/webservice/upload.php Check for a valid json response with a generated item id. e.g. [ {"component":"user","contextid":"28","userid":"16","filearea":"draft","filename":"upload.txt","filepath":"\/","itemid":955505089,"license":"allrightsreserved","author":"Officer Barbady","source":""} ] Run unit tests: ./vendor/bin/phpunit webservice/tests/externallib_test.php
    • Difficulty:
      Difficult
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-22236-master
    • Story Points:
      40

      Description

      Find a way to send any files to any draft file area in Moodle and use them in the web service calls.

      Original issue description:

      Sending files to hub currently works but the design has been refused by Petr because it uses ws token in a POST request with $_FILES. After talking with Dongsheng and Petr, the conclusion was we will be sending files by web service (probably called in a cron script, if the file is too big). And biggest files will be chunked in order to be sent. It implies to write a new file web service design.
      Downloading files could need to follow the same design...

        Attachments

          Issue Links

            Activity

              People

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

                Dates

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