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

Design way to send files by web service (upload)

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.0
    • 2.6
    • Hub
    • MOODLE_20_STABLE
    • MOODLE_26_STABLE
    • MDL-22236-master
    • Difficult
    • 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
    • 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

              damyon Damyon Wiese
              jerome Jérôme Mouneyrac
              Jérôme Mouneyrac Jérôme Mouneyrac
              Sam Hemelryk Sam Hemelryk
              David Monllaó David Monllaó
              Aya Saad, David Mudrák (@mudrd8mz), Helen Foster, Víctor Déniz Falcón
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                18/Nov/13