consider having better handling of array values
Currently, array values get serialized as comma-separated strings. This is less than ideal since the only real reason to use FormData over json is to handle files, and servers have a hard time figuring out your binary from strings like "[object Object], [object Object]".
Therefore, please consider changing: https://github.com/funtusov/ember-cli-form-data/blob/master/addon/mixins/form-data-adapter.js#L18
Ember.keys(data[root]).forEach(function(key) {
if (typeof data[root][key] !== 'undefined') {
formData.append(root + "[" + key + "]", data[root][key]);
}
});
to...
Ember.keys(data[root]).forEach(function(key) {
if (Ember.isArray(data[root][key])) {
data[root][key].forEach(function(value) {
formData.append(root + "[" + key + "][]", value);
});
} else if (typeof data[root][key] !== 'undefined') {
formData.append(root + "[" + key + "]", data[root][key]);
}
});
If this is something we're interested in doing, please let me know and I will submit a PR after I fail my presentation on June 2nd
Thanks for the issue, @foxnewsnetwork. I agree that it's a problem that arrays are not supported, good catch!
The problem I see is that different adapters can implement array serialization in different ways. The best approach could be to let the serializer handle array serialization. Maybe you could investigate using something like DS.Adapter#serialize to handle serialization away?