Insert a text file containing logs into a SQLite database - ios

I had use a method to redirect all my logs into a text file. The problem is that i do not know how to store the text file into the SQLite database.

I would use Blob fields. here is a description how to do it. And of course the content of the file should be stored. The file itself can be stored elsewhere, with a HTTP POST...

Related

Add placeholder to file name without being a chunked key?

I'm currently using fluentd to write out log messages to a file with the file output plugin. Is there a way to use a field in the log message as a placeholder in the file name without specificing it as a chunked key?
No, unfortunately you can not.
https://docs.fluentd.org/output/file
https://docs.fluentd.org/configuration/buffer-section

Finding file type of NSData recieved from server

I am receiving a text file from a socket over TCP/IP. There is no file extension (or filename for that matter) as the data is received as bytes. I can take the data from this (in the form of NSData) and load it into a UITextView and display it fine.
I want to persist this data to a file. However, I don't know what format the data is in (txt, rtf, doc, docx)? I assume it as .txt and save it in the documents directory, but is there a programmatic way of finding out for sure? I've looked around StackOverflow and at the documentation and haven't been able to find anything.
And is there a way to get the details of the file attributes like the file creation date.
Thanks in advance.
When you send a file over a TCP/IP connection, only the file contents will be converted to data and be passed across. If you want the filename,extension and the file attributes, then you will have to add those details separately and append it with the data to be sent. Then you can parse it at the receiver end and use the results inside your app.
You can choose the file type you want when you save the data, you can get attributes from file,please refer to Get file creation date.

How to store content of text area from nicEdit with formatted text in a database

I am using the nicEdit editor for a text area, which may have text, image, links and other formated text. I don't know what datatype to use in a MySQL database to store its content.
If there is any other way to handle this stuff, please suggest.
You can try to save the data in a text column. I think it is a good idea to encode the data before saving. For example, save it as base64 (if you don't have to search in the content), or as url encoded string.
If the images are uploaded to the server, you have to save the images on the webserver too. A few options are:
Use Blob fields (binary large objects) to save the images
Convert the images to an base64 string directly for use in the html code.
Save the images on the file system, not the database
In my tests, options 1 and 2 create a lot of data. So it is better to save the images on outside the database.
Hope this Helps.

How to access paperclip attachments on server side?

I am using paperclip to attach an excel file to a mode.
The purpose is to import the data from the excel file to the database.
Model: Import
has_attached_file: spreadsheet
For the import process, I want to access the file in my model as following.
path = "#{Rails.root}/public/#{spreadsheet.url}"
This doesn't work. I guess because the url has the timestamp at the end.
In general what is the best way to access the attachments on server side ?
I think you're looking for the to_file method. You should be able to do something like this:
excel_file = self.spreadsheet.to_file
which will either return the uploaded file from the server (if you're using s3 or remote storage), or if it has been assigned to the model but not actually stored yet (if you haven't called model.save since it was uploaded), it returns the temp file stored on disk.
From there you should be able to use an excel gem or library to parse the contents.
Alternatively, you can use spreadsheet.url(nil, false) - the second parameter denotes whether or not to append a timestamp.
#spreadsheet.path
http://rdoc.info/gems/paperclip/2.3.8/Paperclip/Attachment#path-instance_method

store PDF file in DB as byte

I am using Asp.Net MVC. in my project while uploading PDF file we convert the PDF file into byte then store it in DB. but i got the following exception.
" String or binary data would be truncated.
The statement has been terminated."
Can any one solve this issue.I got the exception righ here
context.SubmitChanges();
Thanks:
Suresh
Just change the size of your field, try varbinary(MAX).
This is most probably because the code attempted to insert more data/bytes in your database column than its defined size.

Resources