ddavison / rest-client

A simple REST client for the Atom editor!
http://atom.io/packages/rest-client
MIT License
53 stars 29 forks source link

Cannot open in separate editor on Windows 10 #42

Open blokeley opened 8 years ago

blokeley commented 8 years ago

To replicate:

  1. GET https://www.google.com/
  2. Select 'Open in separate editor'.

Atom error dialog:

Cannot save to tmp directory... 
{"errno":-4058, "code":ENOENT, "syscall":"open, "path":"C:\\tmp\\GET - www.google.com"}
ddavison commented 8 years ago

i'm unable to replicate getting this error, but i do notice that it doesn't open correctly.

upon clicking "Open in separate editor", i see that it does put the file with the appropriate contents in C:\tmp\GET - www.google.com but it doesn't open it in atom. will definitely have to take a closer look at this.

ajelinek commented 8 years ago

I have the same issue on Windows 7 box

ddavison commented 8 years ago

so, i did some more research, and this happens when C:\tmp\ doesn't exist to save a file in it. Two possible solutions i can see:

  1. We can have the REST client create this directory first, or...
  2. Utilize the temp npm package to save temporary files.

I think i like option 2 best because this will utilize platform specific temp locations. the temp package i believe uses %TEMP% in windows

signothefish commented 7 years ago

I got it working in Windows. Edit .atom\packages\rest-client\lib\rest-client-editor.coffee, line 12:

@path = process.env.TEMP + "\\#{@file_name}.json"

Just give it the extension of the payload type you expect.

philipsimonhall commented 5 years ago

This worked for me too, but I don't think you need to include the file extension, at least not if you're using Content-Type: application/json in the headers.

I also added .replace('?', '') to line 31 for when parameters are being passed in the URI. Not very elegant, but it works.