Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Allow requests without files #83

Closed
warappa opened this issue Apr 10, 2013 · 5 comments
Closed

Feature: Allow requests without files #83

warappa opened this issue Apr 10, 2013 · 5 comments
Labels

Comments

@warappa
Copy link

@warappa warappa commented Apr 10, 2013

I have the following situation:

In an entity edit-form a user can select an image via <input type="file"/>. Additional data like firstname, lastname,... are sent within this request.

If the user doesn't want to change/set an image, I still want to send the other form-data.

Right now it stops before sending the request at the following line in FileAPI.core.js:

if( ( proxyXHR.statusText != 'abort' || proxyXHR.current ) && data ){

because data (file) is undefined because no file is specified.

I think it should be possible to send the data without any files because if it's not, I only have the following options left:

  • send a dummy file (not so good)
  • use another send algorithm in no-file-case (worst)

What do you think?

Lg
warappa

@RubaXa
Copy link
Collaborator

@RubaXa RubaXa commented Apr 11, 2013

I agree with you, thought long over this situation, will try to do this week.

RubaXa added a commit that referenced this issue Apr 12, 2013
@RubaXa
Copy link
Collaborator

@RubaXa RubaXa commented Apr 12, 2013

Done, you can try in "dev" branch.

@ghost
Copy link

@ghost ghost commented Jun 18, 2013

In IE < 10 we have problems with XHR._send.

In Flash.XHR._send we are falling back to parent _send if we haven't any real files to send. But our formData is not in htmlForm, so we're going to the single piece upload part and crashing on

    var bytes = Array.prototype.map.call(data, function(c){ return c.charCodeAt(0) & 0xff; });
    xhr.send(new Uint8Array(bytes).buffer);

cause IE < 9 doesn't have Array.map and Uint8Array

For the workaround, I've extended toData meth in Flash.Form patch by simple checking existance of files in items and fallback to the parent if we haven't any.

@RubaXa
Copy link
Collaborator

@RubaXa RubaXa commented Jun 18, 2013

Oops, you're right, will correct soon.

@RubaXa
Copy link
Collaborator

@RubaXa RubaXa commented Oct 6, 2013

@RubaXa RubaXa closed this Oct 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.