Feature: Allow requests without files #83

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

Comments

Projects
None yet
2 participants
@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

This comment has been minimized.

Show comment Hide comment
@RubaXa

RubaXa Apr 11, 2013

Collaborator

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

Collaborator

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

This comment has been minimized.

Show comment Hide comment
@RubaXa

RubaXa Apr 12, 2013

Collaborator

Done, you can try in "dev" branch.

Collaborator

RubaXa commented Apr 12, 2013

Done, you can try in "dev" branch.

This comment has been minimized.

Show comment Hide comment
@ghost

ghost 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.

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

This comment has been minimized.

Show comment Hide comment
@RubaXa

RubaXa Jun 18, 2013

Collaborator

Oops, you're right, will correct soon.

Collaborator

RubaXa commented Jun 18, 2013

Oops, you're right, will correct soon.

@RubaXa

This comment has been minimized.

Show comment Hide comment
@RubaXa

RubaXa Oct 6, 2013

Collaborator
Collaborator

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