I am currently trying to recover FAQ data from a mysql database, as the system is
will be shut down soon and unfortunately the user interface does not support FAQ export.
Below is a data frame FAQ_RAW , what is the method to decode and save or possibly output the $ content?
The $content includes png, jpeg and pdf data.
As a newbie to rStudio, maybe any of you know of some good literature/tutorials on this topic?
> str(FAQ_RAW)
'data.frame': 2 obs. of 11 variables:
$ id :integer64 78 79
$ faq_id :integer64 61 61
$ filename : chr "SH0051 STAWS NHK sitzt fest.pdf" "image.png"
$ content_size : chr "1172454" "295778"
$ content_type : chr "application/pdf" "image/png; name=\"image.png\""
$ content :List of 2
..$ : raw 25 50 44 46 ...
..$ : raw 89 50 4e 47 ...
$ inlineattachment: int 0 1
$ created : POSIXct, format: "2020-03-18 12:42:12" "2020-03-18 12:42:12"
$ created_by : int 6 6
$ changed : POSIXct, format: "2020-03-18 12:42:12" "2020-03-18 12:42:12"
$ changed_by : int 6 6
FAQ_RAW is a big list of things that arent the raws, its all the metadata too.
try to write the first item the SH0051 pdf FAQ_RAW$content[[1]]
also I would want to write it out to a file connection (so that I could try to open the file) rather than write it to binary data stored in some variable.
so look into file connections.
something like
> myfile <- file("mynewfile.pdf","rwb")
Error in file("mynewfile.pdf", "rwb") : cannot open the connection
In addition: Warning message:
In file("mynewfile.pdf", "rwb") :
cannot open file 'mynewfile.pdf': No such file or directory
>
it is not necessary to create the file mynewfile.pdf first ?
Plan B would be to do the job of downloading to a directory using php script.
UPDATE: Plan B works fine
Last Question: Is there a method to trigger PHP script with R?