Files from website to NAV 2009
andersthue
Member Posts: 3
Hi All
I'm a web developer and I only have a little understanding of NAV so please have patience with me
I have made a .NET website where you can upload a file to NAV 2009 R2 and later download it through the webservcie.
Edit : The code is based on this post : http://www.kauffmann.nl/blog/index.php/ ... b-service/
The problem is that one pdf file do not work when downloaded, and when i look at the file content it has been padded with 0x00 and is somewhat larger than the original file.
All other files work, and images are correctly displayed in NAV...
I use this code to upload:
And this code for download (it's a ashx file)
Any suggestions ?
Regards
Anders Thue Pedersen
http://www.andromeda-it.dk
I'm a web developer and I only have a little understanding of NAV so please have patience with me
I have made a .NET website where you can upload a file to NAV 2009 R2 and later download it through the webservcie.
Edit : The code is based on this post : http://www.kauffmann.nl/blog/index.php/ ... b-service/
The problem is that one pdf file do not work when downloaded, and when i look at the file content it has been padded with 0x00 and is somewhat larger than the original file.
All other files work, and images are correctly displayed in NAV...
I use this code to upload:
string picture = Convert.ToBase64String(fileupload.FileBytes);
NAVWebservice.SaveFile(ref string filedata); (pseudo code, it's wrapped in a data access layer)
And this code for download (it's a ashx file)
string picture = string.Empty;
NAVWebservice.GetFile(ref string filedata); (pseudo code, it's wrapped in a data access layer)
byte[] buffer = Convert.FromBase64String(picture);
HttpResponse response = HttpContext.Current.Response;
response.ContentType = contenttype ;
response.AppendHeader("content-disposition", "inline; filename=" + filename);
response.ClearContent();
response.OutputStream.Write(buffer,0,buffer.Length);
response.End();
Any suggestions ?
Regards
Anders Thue Pedersen
http://www.andromeda-it.dk
0
Answers
-
And as noted in the comment in the original post (that was down when i tried to figure out this error) the error was that the receiving code in NAV was
Bytes := MemoryStream.GetBytes():
But should beBytes := MemoryStream.ToArray():
Regards
Anders0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K 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
- 323 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