This is not a bug with Image Editor. I just wanted to post this here for informational purposes in case anyone ever runs into it.

If you use Varnish and are using some default.vcl settings recommended by Lullabot, you will get the error "Failed uploading: [object XMLHttpRequest]". This is due to this setting:

# Always cache the following file types for all users.
if (req.url ~ "(?i)\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm)(\?[a-z0-9]+)?$") {
  unset req.http.Cookie;
}

Remove "png|gif|jpeg|jpg|" from the REGEX and you're all good. I hope I save someone else's hair! :D

BTW outstanding module! Totally blows away any other cropping/editing module! Thank you!

Comments

duozersk’s picture

Title: Failed uploading: [object XMLHttpRequest] » Varnish compatibility: Failed uploading: [object XMLHttpRequest]
Component: Miscellaneous » Code
Assigned: Unassigned » duozersk

Hi,

Thanks for the report! I renamed it to state that it is Varnish related.

Looks like the GET request wasn't the best way to process the saving :) I can change it to POST so that it doesn't conflict with the recommended Varnish settings. It will first get into 7.x and then will be back ported to 6.x.

Thanks again!
AndyB

duozersk’s picture

Well... seems like some editors just require the GET type of callback.

Will try to talk to Lullabots - maybe they have some ideas about it :)

AndyB

duozersk’s picture

Might be that if I add "/ajax/" to the callback URLs - then all should be fine with Varnish...

jrstmartin’s picture

In the meantime, do you know the path I could exclude from Varnish caching to make it work? I tried excluding node/add from the rule but didn't work. I still get the error mentioned above.

  if (req.url ~ "(?i)\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm)(\?[a-z0-9]+)?$" && !req.url ~ "^/node/add/.*$") {
    unset req.http.Cookie;
  }

Thanks.

duozersk’s picture

Sure, just anything under "imageeditor/*" will do the trick, or if you want to be more specific, try with "imageeditor/save/*" and "imageeditor/exit/*" (but there might be smth else).

Thanks
AndyB

jrstmartin’s picture

Works! Thank you! Rather obvious :D. In default.vcl in sub vcl_recv:

# Do not cache these paths.
if (req.url ~ "^.*/imageeditor/.*$") {
     return (pass);
}
kourosh.a’s picture

Hi guys, I don't use Varnish, but I get the exact same error when I try to save the edit image file... anyone has any idea ?

duozersk’s picture

Category: bug » support
Status: Active » Closed (works as designed)

Kourosh,

Please open a new issue with your specific details (like what editor did you use, when the error pops up, etc.). This one is specific to Varnish reverse proxy cache.

Reclassifying it to a support request (as you can tweak Varnish settings to allow Image Editor to work fine) and closing.

Thanks
AndyB