WorkLight SQL Adapter : Upload an image using SQL Adapter - ibm-mobilefirst

I need to upload an image to database as blob type using SQL Adapter And also i need to know how to get blob data from SQL Adapter.Will you please help me for inserting and retrieving blob data through SQL Adapter.

Taken from an old forum post:
Here is what I think of.
Write a servlet or whatever equivalent in your app server. In the servlet, you fetch the image from DB.
Encode the image binary contents according to BASE64.
Return the base64 string of the image.
Write an HTTP Adapter to visit the servlet you just write.
In your client application, you can insert the image into a by setting the "src" attribute to some value like
"data:charset=some_charset, ". For example,
"data:image/gif;base64,".
Message by MingZheHuang.

Related

I need to upload media content (video or image) storage in SQL Azure to Azure BLOB Container

Actually the information is stored in BASE64 in a varchar field. I've created a stored procedure to convert that field into varbinary. With the following code:
cast(N'' as xml).value('xs:base64Binary(sql:column("[name of the column]"))', 'varbinary(MAX)')
The result is shown in the following picture:
The media is storage (SQL Azure) in varbinary, after storing the media content as file in the BLOB Container, I cannot be able to render the media to watch its content if I donwload it in my local computer. Even If I try to open the file with a local editor I can see the same value as the image shows above.
All the convertion process is running in Azure SQL Server and call it using a ADF process.
What is the best approach to load those media using Azure Data Factory? Is it another way to save BASE64 to image from SQL to Blob storage in AZURE?
Thanks
You will have to convert Varbinary data type back to Base 64 and then save it to Blob.
You can refer to this and see which method you would like to implement out of an answer by Manoj Choudhari or Divya Agarwal.

How to use SQL Server Reporting Services URL Access to save rendered PDF-Reports as varbinary into Table

I'm trying to store rendered pdf-reports from the Report Server back into a table of the origin database as a varbinary. My current approach would be to use URL-Access inside of an external python script to get the rendered reports and then save them into the corresponding table. The following URL works as expected in the browser:
http://localhost/reportserver?/ReportingServicesTest/Report_Test&rs:Format=PDF
However when I tried to access that URL inside of the external python script I received a 401 error.
So I then tried to use the requests_ntlm library to pass the username and password, but somehow it still doesn't work.
import requests
from requests_ntlm import HttpNtlmAuth
url = 'http://localhost/reportserver?/ReportingServicesTest/Report_Test&rs:Format=PDF'
session = requests.Session()
session.auth = HttpNtlmAuth('Domain\\Username','password')
response = session.get(url,stream=True)
open('C:/Path/Report_Test.pdf', 'wb').write(response.content)
Is my approach in principle correct or are there better ways to accomplish the same thing?
I'm fairly new to SQL Server Reporting Services, so I'm open to your suggestions and appreciate your help in advance.
IMHO if you need to historic data for safekeeping or auditing purposes I'd strongly recommend to keep the data in the database. Use a staging environment to add a timestamp to the report data so the snapshots make more sense. In this way you can use the SSRS portal later on to filter on a particular historic version (parameterized) and you don't have to build a bespoke PDF viewer. It would also save some database storage. As an alternative, you could create a subscription in SSRS, have the PDF send to a file share. Then configure a listener to that directory to get your meta information and store that reference in a database table. Needless to say I'm not a big fan of storing files in the database as file storage is cheaper than database storage most of the time.
To solve your authentication issue you might want to check up on your rsreportserver.config file on your web server as your current code suggests that your local host is unknowing of any domain. In any case you can try changing your <Authentication/> section so that it looks like this:
<Authentication>
<AuthenticationTypes>
<RSWindowsBasic>
<LogonMethod>3</LogonMethod>
<Realm></Realm>
<DefaultDomain>putyourfullyqualifieddomainnamehere</DefaultDomain>
</RSWindowsBasic>
</AuthenticationTypes>
<RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel>
<RSWindowsExtendedProtectionScenario>Proxy</RSWindowsExtendedProtectionScenario>
<EnableAuthPersistence>true</EnableAuthPersistence>
</Authentication>
This will also work if your web server is behind a proxy or firewall.
Important: the content of DefaultDomain should be a FQDN, such as contoso.microsoft.com or myprimarydomain.lan

I'm having trouble retrieving data product from cloud database in JSON format

I'm supposed to retrieve product data from a cloud database in JSON format. This is the link of the data: http://bi.edisonsiow.com/ay1516s2/ca1/getProducts.php
How am I supposed to do it? I'm using SQL Server Management Studio.
this link might help you....
https://www.simple-talk.com/sql/t-sql-programming/consuming-json-strings-in-sql-server/
it creates a TSQL function to read json

Populate SWF with SQL data

I designed a Flash application that takes data from an XML file and populates a datagrid and textFields.
I need to access a SQL database instead of XML.
Can you lead me in the right direction? I have seen Flash Builder access SQL, but I am not sure how to populate the datagrid in the SWF. The SWF contains a map and other graphic elements and animation.
Thanks.
Simple answer is that you create a PHP file that accesses the database and prints/echoes the MYSQL data as your XML. Using the URLLoader class you can load this php file and have the xml as the loaded data. The rest should then be the same as your existing app.
You can add get variables to the url string used in the URLLoader or you can use URLVariables to use post variables to pass values if necessary to your php script.

Image Saving explanation

I have manage to write images on an sql server 2008
But i see that in the image record writing the same bytes in all of the images
And also it creates on the remote disk under a special catalogue a file which finally is the image
Is there anybody which can explain me the flow chart of writing an image in sql server?
What is contained in the image record?
Here are a couple of tutorials on saving image data in a FILESTREAM column in SQL Server 2008:
http://blogs.msdn.com/rdoherty/archive/2007/10/12/getting-traction-with-sql-server-2008-filestream.aspx
http://lennilobel.wordpress.com/2009/09/22/sql-server-2008-filestream-part-1-of-3-introducing-filestream/
http://lennilobel.wordpress.com/2009/10/06/sql-server-2008-filestream-part-2-of-3-enabling-and-using-filestream/
http://lennilobel.wordpress.com/2009/10/20/sql-server-2008-filestream-part-3-of-3-using-the-opensqlfilestream-api/