How to creat and read databse in actionscript3 ( ini or sql )? - sql

I need a way to create a swf application that creates a file in the same folder that my swf will be and to be able to read and write stuff on it so i can have a "save" file.
I wanna know if that's possible and the easiest way for me to do it.
Thanks

About the database, you have a similar question here and also a positive answer, hope will help you.
To save your file you will need to use the File API
var file:File = File.desktopDirectory.resolvePath("myFileName.txt");
var stream:FileStream = new FileStream();
stream.open(file, FileMode.WRITE);
stream.writeUTFBytes("This is my text file.");
stream.close();

Related

Indexing a document with content using solrj in EmbeddedSolrServer

I want to query an EmbeddedSolrServer instance with a Filter query. Like we normally do in the picture with an admin panel. But the problem here is that I want to do this programmatically with Java. I know that we can do that query.setQuery("*:*"); , but this is not what I want if someone want to search by a specific word in content's document. I found also this solrParams.add(CommonParams.QT, "*:*");, But it's not working. I think that may be the problem is from parsing the PDF document, when I try to index it. So please if someone know how to index a document using EmbeddedSolrServer exactly the same way we index it using post.jar in command.
Indexing a file is as easy as
EmbeddedSolrServer server = new EmbeddedSolrServer(solrHome, defaultCoreName)
ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update/extract");
req.addFile(fileToIndex, "application/octet-stream");
req.setParam("commit", "true");
req.setParam("literal.id", id);
NamedList<Object> namedList = server.request(req);
server.close();

Reading Images, Pdf from SQL Database via LINQPad

I have a table in a database that contains all kind of attachments, images, pdf, excel, and other formats. creating an application is not an option, so I googled other options and I found this related question that mentioned LINQPad I downloaded it but I still do not know how exactly it works. Anyone please explain that to me? I can query the attachments using sql query but not sure how to dump them and preview them via the mentioned tools.
Following on from Dan's answer, once you have the data context set up you can dump the images from the database. I use this snippet for checking an image I've written to the database, you should be able to edit as required to match your scenario:-
var ii = ItemImages.Where (v => v.Id == 10).FirstOrDefault();
using (var ms = new MemoryStream(ii.Image.ToArray()))
{
System.Drawing.Image.FromStream(ms).Dump();
}
Use the Util.Image built in utility for images.
Ex:
var personPictures = PictureTable.Take(1);
Util.Image(personPictures.First().Picture).Dump();
Util.Image takes a byte array.
Depending on your database of your choice, most likely you'll need a data context driver
http://www.linqpad.net/richclient/datacontextdrivers.aspx
Once you establish a connection you can start writing queries against the data

VB: Return a pdf without create

I'm developing a MVC web app in VB.Net and I have a pdf in base64 string format. It's possible to return that pdf to the view and see it, without creating a temp.pdf file?
You say in a comment that you want something like:
Return File(System.AppDomain.CurrentDomain.BaseDirectory & "\file.pdf", "application/pdf")
So why not simply:
Return File(Convert.FromBase64String(base64string),"application/pdf")
References:
Convert.FromBase64String
File

sahi script for choosing and uploading a file

I'm using Sahi for Test Automation of web application. I have to write a script for sahi for uploading a file. But unfortunately I don't know the way. Can anybody please help me?
File upload can be a complex thing depending upon any validations you do on the upload. For a starter, you can try out the following:
Synatx:
_setFile(element, filePath [, actionURL])
eg:
_setFile(_file("id"), "C:\abc\efg.jpg", "formSubmit.jsp");
If there are javascript validations on the file field, you can try this hack. Before submitting the file, change the field’s type to “text”, and then set its value. Eg.
// set the file
_setFile(_file("file"), "scripts/demo/uploadme.txt");
// Change the "type" attribute of file field
if (_isIE()){
_call(_file("file").outerHTML = _file("file").outerHTML.replace(/type=['"]?file['"]?/, "type=text"));
}else{
_call(_file("file").type = "text");
}
// Set the value into the textbox
_setValue(_textbox("file"), "scripts/demo/uploadme.txt");
This works for most of the cases. If you still get any error, you can post it here.
Thanks,
Vivek
You can use the following
_setFile(_file("id"), "C:\\abc\\efg.jpg");
Not sure if you need anything more complex?
Note that as of Sahi 4.3, there is a _setFile2 function that automatically handles js validations and does this input type conversion.
I've solved using the function setFile2, with internally changes the type of field to text

Create files using list of filenames and add content to each

I need to make a bunch of redirect pages as I've recently updated my web site which previously used .html files and now all the files are .aspx. I have a tab-delimited file containing a list of original filenames and the corresponding new filename.
It seems like there should be a language out there that I should be able to create a file using the first column for the filename and insert the second column as its content with some additional text for the 301 redirect.
Could someone point me in the right direction as to what language(s) would be able to accomplish this? Also, if you could also point out the name of the method/function I would be using so I know where to begin when creating the file.
I've needed to do this type of thing many times and am willing to learn a new language (Perl, Python, or whatever) to accomplish this, but I just need pointed in the right direction. I am using Windows XP to develop on.
Thank you for your time.
This can be done in a few lines of C# if you already are working with aspx you can process this in the codebehind on a dummy page.
System.IO.StreamReader myreader = new System.IO.StreamReader(Server.MapPath("~/Text.txt"));
while (!myreader.EndOfStream)
{
//9 is Ascii value of Tab bad idea to split if the second set of values might contain tabs but can reconstruct the data if inputString.length >2
string[] inputString = myreader.ReadLine().Split(char.ConvertFromUtf32(9).ToCharArray());
//construct the path to where you want to save the file, or if the filename is the full path all the better
System.IO.StreamWriter filemaker = new System.IO.StreamWriter(#"C:\" + inputString[0]);
filemaker.Write(inputString[1]);
filemaker.Close();
}