sealcode / sealious

An extensible, declarative node framework
25 stars 2 forks source link

Methods PATCH & PUT don't work with field type file #244

Closed arkadiusz-wieczorek closed 8 years ago

arkadiusz-wieczorek commented 8 years ago

I've discovered that PATCH & PUT methods don't work with field type file. When I sent PATCH or PUT to existing resource with new file, I received this error:

{
    "data": {
        "file": "Wrong file data format. Should be <Buffer>, but received undefined"
    },
    "is_error": true,
    "type": "validation",
    "status_message": "There are problems with some of the provided values."
}
01:26:08.879 - error:   PATCH /api/v1/person/r5jk9ddk2g
            from: 127.0.0.1, mime: multipart/form-data
            result: failed - There are problems with some of the provided values.
Error: There are problems with some of the provided values.
    at new SealiousErrors.Error (/home/arkadiusz/Projects/hello-world/node_modules/sealious/lib/response/error.js:6:12)
    at new SealiousErrors.ValidationError (/home/arkadiusz/Projects/hello-world/node_modules/sealious/lib/response/error.js:21:12)
    at /home/arkadiusz/Projects/hello-world/node_modules/sealious/lib/chip-types/resource-type.js:175:28
    at bound (domain.js:250:14)
    at runBound (domain.js:263:12)
    at tryCatcher (/home/arkadiusz/Projects/hello-world/node_modules/sealious/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/home/arkadiusz/Projects/hello-world/node_modules/sealious/node_modules/bluebird/js/main/promise.js:503:31)
    at Promise._settlePromiseAt (/home/arkadiusz/Projects/hello-world/node_modules/sealious/node_modules/bluebird/js/main/promise.js:577:18)
    at Promise._settlePromises (/home/arkadiusz/Projects/hello-world/node_modules/sealious/node_modules/bluebird/js/main/promise.js:693:14)
    at Async._drainQueue (/home/arkadiusz/Projects/hello-world/node_modules/sealious/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/home/arkadiusz/Projects/hello-world/node_modules/sealious/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/arkadiusz/Projects/hello-world/node_modules/sealious/node_modules/bluebird/js/main/async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:371:17)
------WebKitFormBoundary1l2BQEaJzZ5OWM3W
Content-Disposition: form-data; name="file"; filename="1_283.png"
Content-Type: image/png

------WebKitFormBoundary1l2BQEaJzZ5OWM3W--
new Sealious.ChipTypes.ResourceType({
    name: "person",
    fields: [{name: "file", type: "file"}]
});
kuba-orlik commented 8 years ago

For some reason www-server does not wrap file buffers in Sealious.File. Probably has to do with the fact that /resource_type/id does not check resource_type's handles_large_data flag. WIll look into it :)

arkadiusz-wieczorek commented 8 years ago

Ok

kuba-orlik commented 8 years ago

Hi, sorry for the delay. The issue is fixed in channel-rest. Please update your application's channel-rest to v0.1.4. If the issue is resolved for you, please close this issue.

arkadiusz-wieczorek commented 8 years ago

Thanks for feedback, I will check this tomorrow :)