Skip to content
This repository was archived by the owner on Jan 24, 2019. It is now read-only.

Ui uploader data #401

Merged
merged 2 commits into from May 19, 2015
Merged

Ui uploader data #401

merged 2 commits into from May 19, 2015

Conversation

ghost
Copy link

@ghost ghost commented May 17, 2015

ui-uploader not supported additional parameters to the upload POST request.

Variable named "data" is declared in the beginning og "ajaxUpload" function.

function ajaxUpload(file, url) {
        var xhr, formData, prop, data = '',
            key = '' || 'file';

Later on in this function, there is a code that check if data not empty, to add all its properties to the formData object as request parameters (POST variables...)

        // Append additional data if provided:
        if (data) {
            for (prop in data) {
                if (data.hasOwnProperty(prop)) {
                    formData.append(prop, data[prop]);
                }
            }
        }

But there is no way to populate this variable with data (the if statement in the previous example will never evaluate as "true").

As a result, the only way to add parameters to the upload request is using the query string (changing the URL) instead of using request body.

The solution (without breaking backword compitability) is to add 3rd argument "data" to "ajaxUpload". This argument is populated from "options.data".

PowerKiKi added a commit that referenced this pull request May 19, 2015
Ability to add data to query via ``options.data``
@PowerKiKi PowerKiKi merged commit f30c359 into angular-ui:master May 19, 2015
@PowerKiKi
Copy link
Contributor

Thanks a lot

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants