File upload to webserver

InnerCode
Member Posts: 8
Hi all,
I've build a codeunit that runs a report and save that as an xlsx. After that it must be uploaded to a webserver.
I can do a HTTP request using the Automation object "Microsoft XML, v6.0.XMLHTTP60" but it seems that it only supports text.
Than I tried to convert the file to a base64 string by using the DotNet mscorlib System.Convert component but it don't work and hangs on a "Ambiguous function call, no matching method found" error. That error can occur when the function have nullable fields. I don't know how to resolve that.
So, does someone know how to upload a file using HTTP? I'm stuck for 3 days now.
Many thanks in advance
I've build a codeunit that runs a report and save that as an xlsx. After that it must be uploaded to a webserver.
I can do a HTTP request using the Automation object "Microsoft XML, v6.0.XMLHTTP60" but it seems that it only supports text.
Than I tried to convert the file to a base64 string by using the DotNet mscorlib System.Convert component but it don't work and hangs on a "Ambiguous function call, no matching method found" error. That error can occur when the function have nullable fields. I don't know how to resolve that.
So, does someone know how to upload a file using HTTP? I'm stuck for 3 days now.
Many thanks in advance
0
Best Answer
-
Hi
I've used System.Convert.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' for same purpose with success like this:
---
XMLElementField := XMLDocument.CreateElement(Name2XMLEntry(ElementName));
IF EXISTS(URL) THEN BEGIN
PictureFile.OPEN(URL);
PictureFile.CREATEINSTREAM(InStream);
MemoryStream := MemoryStream.MemoryStream;
COPYSTREAM(MemoryStream, InStream);
XMLElementField.AppendChild(XMLDocument.CreateTextNode(Convert.ToBase64String(MemoryStream.GetBuffer)));
END;
XMLElementTable.AppendChild(XMLElementField);
---
I also use:
System.IO.MemoryStream.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
2
Answers
-
Hi
I've used System.Convert.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' for same purpose with success like this:
---
XMLElementField := XMLDocument.CreateElement(Name2XMLEntry(ElementName));
IF EXISTS(URL) THEN BEGIN
PictureFile.OPEN(URL);
PictureFile.CREATEINSTREAM(InStream);
MemoryStream := MemoryStream.MemoryStream;
COPYSTREAM(MemoryStream, InStream);
XMLElementField.AppendChild(XMLDocument.CreateTextNode(Convert.ToBase64String(MemoryStream.GetBuffer)));
END;
XMLElementTable.AppendChild(XMLElementField);
---
I also use:
System.IO.MemoryStream.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
2 -
lynge: You rock! Many thanks for your example code!!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