How to download image from URL to BLOB

simekRadim
Member Posts: 6
Please, can anybody tell me how to figure this out? I have an image URL (for example: http://domain.com/picture.png) and I want to download it to BLOB type variable.
Thanks in advance.
Thanks in advance.
0
Answers
-
Hi,
Use DotNet "System.Net.WebClient" to open the file from your URL and save it into Stream. And then save to your BLOB.
Oh no! It not work for CC
Regards,Make Simple & Easy0 -
Hi,
You can use below code for download the image from web and save it local. After that you need to read downloaded file and save it into BLOB.usage fnDownloadImage('http://static.adzerk.net/Advertisers/5fa811fa1a3e40f1a3435478bd1364a0.png','C:\Dummy\p.png',1); function name : fnDownloadImage Var Name DataType Subtype Length No ptxtUrl Text 1024 No ptxtSaveAsFileName Text 1024 No poptSaveAsOption Option Name DataType Subtype Length atXMLHTTP30 Automation 'Microsoft XML, v3.0'.XMLHTTP30 atAdodbStream Automation 'Microsoft ActiveX Data Objects 6.1 Library'.Stream IF STRLEN(ptxtUrl) = 0 THEN EXIT(FALSE); CREATE(atXMLHTTP30,FALSE,TRUE); atXMLHTTP30.open('GET', ptxtUrl,FALSE); atXMLHTTP30.setRequestHeader('Content-type','image/png'); atXMLHTTP30.send; CASE atXMLHTTP30.status OF 200: BEGIN CREATE(atAdodbStream,FALSE,TRUE); atAdodbStream.Type := 1; // adTypeBinary atAdodbStream.Open; atAdodbStream.Write(atXMLHTTP30.responseBody); atAdodbStream.SaveToFile(ptxtSaveAsFileName,poptSaveAsOption + 1); // adSaveCreateNotExist = 1, adSaveCreateOverWrite = 2 atAdodbStream.Close; END; ELSE MESSAGE('%1',atXMLHTTP30.statusText); END; IF NOT ISCLEAR(atAdodbStream) THEN CLEAR(atAdodbStream); IF NOT ISCLEAR(atXMLHTTP30) THEN CLEAR(atXMLHTTP30); EXIT(TRUE);
Regards,Make Simple & Easy0
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