cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mirko77 <...@git.apache.org>
Subject [GitHub] cordova-plugin-file-transfer pull request: CB-9600 FileUploadOptio...
Date Wed, 13 Apr 2016 09:30:36 GMT
Github user mirko77 commented on the pull request:

    https://github.com/apache/cordova-plugin-file-transfer/pull/121#issuecomment-209334303
  
    I am posting to a Linux server (Ubuntu 14.10), PHP 5.6 backend , from an Ionic1.2.4 app.
    
    Here is the code, I removed the stuff not related to the bug
    
    ```
    
    var uploader = new FileTransfer();
    var options = new FileUploadOptions();
    var upload_URL = $rootScope.serverUrl + PARAMETERS.API_PATH + '/upload/' + slug;
    var file = $rootScope.file;
    var file_URI;
    
    function _onSuccess(r) {}
    
    function _onError(error) {}
    
    // Set options for multipart entity file
    options.fileKey = 'name';
    options.fileName = file.file_name;
    options.params = {
      data: {
        entry_uuid: "3e6450ee-eb6e-5387-0ec7-da7d13c6df30",
        id: "3e6450ee-eb6e-5387-0ec7-da7d13c6df30",
        attributes: {
          form: {
            type: "hierarchy",
            ref: "b8906ef28f944a26a1b7839290a5c2a6_57078c27d0238"
          }
        },
        type: "file",
        relationships: {
          branch: {
    
          },
          parent: {
    
          }
        },
        file: {
          input_ref: "b8906ef28f944a26a1b7839290a5c2a6_57078c27d0238_57078cbf32c50",
          type: "photo",
          name: "3e6450ee-eb6e-5387-0ec7-da7d13c6df30_1460537677.jpg"
        }
      }
    };
    
    if (auth) {
      options.headers = {
        Authorization: 'Bearer ' + auth;
      };
    }
    
    file_URI = file.file_path + file.project_ref + '/' + file.file_name;
    
    //append protocol for file on ios
    if (window.device.platform === PARAMETERS.IOS) {
      file_URI = 'file://' + file_URI;
      options.chunkedMode = false;
    }
    
    uploader.upload(file_URI, upload_URL, _onSuccess, _onError, options);
    ```
    
    content of the POST array of an Android request:
    
    `Array([data] => {
      "entry_uuid": "3e6450ee-eb6e-5387-0ec7-da7d13c6df30",
      "id": "3e6450ee-eb6e-5387-0ec7-da7d13c6df30",
      "attributes": {
        "form": {
          "type": "hierarchy",
          "ref": "b8906ef28f944a26a1b7839290a5c2a6_57078c27d0238"
        }
      },
      "type": "file",
      "relationships": {
        "branch": {},
        "parent": {}
      },
      "file": {
        "input_ref": "b8906ef28f944a26a1b7839290a5c2a6_57078c27d0238_57078cbf32c50",
        "type": "photo",
        "name": "3e6450ee-eb6e-5387-0ec7-da7d13c6df30_1460537677.jpg"
      }
    })`
    
    content of the POST array of an iOS request:
    
    `Array
    ()
    `
    
    



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message