Creating a temporary file and upload it to a ftp (NAV 2016)

madsmorre
Member Posts: 40
Hi
I have issues on how to "attack" this task.
I have to create a csv-file (either by creating a file and write to it or by a xml-port). This file I should upload to a ftp-address. The task has to be without any involvement - is started by an NAV-event.
The task is in two parts then.
1. Create a file in developer environment (temp-file???) - i don't have to use it afterwards
2. Transfer the file to an ftp-server
Again - the task is without any involvement from any person.
I have read and tried a lot, but seems to get stock. I'm used to working in the 2-tier environment and are not yet familiar with the 3-tier.
Does anyone has suggestions to this?
Regards
/Mads Morre
I have issues on how to "attack" this task.
I have to create a csv-file (either by creating a file and write to it or by a xml-port). This file I should upload to a ftp-address. The task has to be without any involvement - is started by an NAV-event.
The task is in two parts then.
1. Create a file in developer environment (temp-file???) - i don't have to use it afterwards
2. Transfer the file to an ftp-server
Again - the task is without any involvement from any person.
I have read and tried a lot, but seems to get stock. I'm used to working in the 2-tier environment and are not yet familiar with the 3-tier.
Does anyone has suggestions to this?
Regards
/Mads Morre
0
Best Answer
-
Seems like your URL does not include the filename itself.
try
URL += parFolder+'/';+ parFileName;
also check this for a full example from a recent thread
https://forum.mibuso.com/discussion/51988/ftp-upload-with-dotnet
Austrian NAV/BC Dev5
Answers
-
Check out Codeunit 419 to create Tempfiles on the server ( function ServerTempFileName, ...)
Then let your XMLPort export into that file using a stream.
For uploading the file onto the FTP there are several ways to do that.
The best, in my opinion is to just use .NET to do that.
Check out the FTPWebRequest class:
https://msdn.microsoft.com/en-us//library/system.net.ftpwebrequest(v=vs.110).aspx
Also there are plenty examples available online.Austrian NAV/BC Dev0 -
HI
I tried this:
URL := parServer;
IF parFolder <> '' THEN
URL += parFolder+'/';
FTPRequest := WebRequest.Create(URL);
Credentials := Credentials.NetworkCredential(parUser,parPW);
FTPRequest.Credentials := Credentials;
FTPRequest.KeepAlive := FALSE;
FTPRequest.UseBinary := TRUE;
FTPRequest.Method := 'STOR';
FTPRequest.UsePassive := TRUE;
FileStream := FileA.OpenRead(parFileName);
FTPRequest.GetRequestStream.Write(FileA.ReadAllBytes(parFileName), 0, FileStream.Length);
Variables:
WebRequest DotNet System.Net.WebRequest.'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
FTPRequest DotNet System.Net.FtpWebRequest.'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Credentials DotNet System.Net.NetworkCredential.'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
FileStream DotNet System.IO.FileStream.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
FileA DotNet System.IO.File.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
URL Text 250
But I get the following error - can you see why
0 -
Seems like your URL does not include the filename itself.
try
URL += parFolder+'/';+ parFileName;
also check this for a full example from a recent thread
https://forum.mibuso.com/discussion/51988/ftp-upload-with-dotnet
Austrian NAV/BC Dev5 -
Here is another solution that works with an option source solution and works with SFTP as well.
https://dynamicsuser.net/nav/b/ara3n/posts/moving-files-in-nav-with-ftp
0 -
Thank you all
I have solved the issue with a little help.
It is exactly as you wrote, Wisa123 - i needed the actual filename (to be) in the code as well.
Thansk for your replies.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions