Couldn't write binary data to file by using write file from desk node

my requirement is list the files from sftp and download the sftp files from SFTP. Below i have attached the my workflow. file will be save as binary in FTP download node so i have used write file from desk node for write the binary data to file and while executing the workflow it always shows error of not writable. below i have attached the write file from desk screenshot and error screenshot So please give me the solution.

@Kaviya_V How did you deploy n8n? If using Docker, you have to add a mount and give the container access to D:\N8n\files. Make sure to give the container permissions on this directory(sudo chown -R 1000:1000 /host/path on Linux), otherwise it will also fail with the same error.

Hi, i Insatlled the n8n locally hosted not from docker

1 Like

I can’t say what’s the issue in that case. But generally speaking, the npm release is not stable and I don’t recommend using it for production. You would want to move to Docker eventually in the future.

Hi @Kaviya_V Welcome!
I guess you should try giving explicit permissions to that path if that works via env variable which is N8N_RESTRICT_FILE_ACCESS_TO which you can setup in windows using set command before running n8n, although i would not agree on NPM version of n8n is not being stable as i am using that only for past 8 months and never faced any issue. Try reading this thread for more information about similar errors:

2 Likes

hi, i set env variable as per you mentioned and n8n start from powershell, it is working but if i closed powershell command prompt, it is again start throws same error. should i keep on open powershell cmd?

1 Like

Hi @Kaviya_V Glad it worked, it is a limitation of those env variables that once the session is closed those values would also be gone although you could go inside CMD configs and permanently edit those but i do not recommend that because those values can sometimes change, so for now the best fix is to install n8n via docker and then edit those in its configs that would always be saved and would be up, just in case if you do not want docker and want NPM like me what i did was:

currently you have used set command but now use setx command that would save everything permanently like setx ENV_NAME=VALUE

Just in case if you want docker:

currently you have used set command but now use setx command that would save everything permanently like setx ENV_NAME=VALUE- could you please clearly say?

1 Like

I mean here you previously might have used this:

set N8N_RESTRICT_FILE_ACCESS_TO=/some/file/path

and as you have confirmed this worked, now i want you to try using this:

setx N8N_RESTRICT_FILE_ACCESS_TO=/some/file/path

And that should permanently save that path so that no matter which session you open this env variable would always be saved across all sessions of CMD and you do not have to re declare again and again when starting n8n via npm command.

sorry, i have used enviroment variable application property for set the path as per screenshot mentioned in forum, So could you please say where should i execute setx N8N_RESTRICT_FILE_ACCESS_TO=/some/file/path? Power shell or command prompt?

1 Like

@Kaviya_V You have to use that command before starting n8n in the COMMAND PROMPT not in power shell. (in the same shell for first run and then test does it work in different sessions or not)

Hi, i put this commmand in nssm and restart the n8n after that it is working fine. Thanks a lot.

1 Like

Hey @Kaviya_V Glad it worked to appreciate my help consider marking that as a solution to let other’s know what is right.

Cheers! Have a nice weekend!