Uploading Business Central Base App.xlf results in "Failed to extract the contents of the uploaded file." - azure-cognitive-services

I try to upload the Base App.xlf file from English into German (by Business Central 15), but everytime I upload the file, I receive an error that says "Failed to extract the contents of the uploaded file." after 2-3 minutes. If I upload a smaller .xlf file, everything is fine.
Base App.xlf: 62.25Mb
Smaller file: 74Kb
Both files are written in xliff version 1.2. Regarding to the post below, Custom Translator supports it in 2018.
Custom translator cannot extract contents of XLIFF file
I can't figure out, why the bigger file is not processed. Some more information would be useful. Is this error thrown cause of special character?

I just figuered out that the Base Application has some missing -tags in the -tags, which leads to the error, obviously. I used an xlst-File to delete tags with missing . This deleted -tags with an empty -tag, too.

Related

mPDF to output a local file + file inline to the browser

I wanna know if i can output a pdf, using mPDF, to a destination as well as a preview in the browser at the same time. ie. I+F at the same time.
I: send the file inline to the browser. The plug-in is used if
available. The name given by filename is used when one selects the
"Save as" option on the link generating the PDF.
F: save to a local
file with the name given by filename
My current code is like this:
$mpdf->Output($OutputLocation,F);
$mpdf->Output();
exit;
It can export the pdf file to $OutputLocation successfully, however, in the browser, it shows:
mPDF error: Some data has already been output to browser, can't send
PDF file
In the documents of mPDF, it has only show one option for one time, any methods to do both in the same output process?
http://mpdf1.com/manual/index.php?tid=125
Please help, thanks.
It turns out that it is an issue on QNAP that their default php.ini is not allowing output buffering.
To solve this, I have edited the php.ini in the WebUI and change the output buffering to 4096. Then it works again.
output_buffering = 4096

Download an excel file as attachment using Qt browser

I am working on Qt browser(code taken from Qt Tab Browser Example). This Qt browser successfully downloads an image file, but not an excel/pdf file. I need to download an excel/pdf file as attachment on click of a button. Excel generation code at back-end uses PHPExcel to generate and finally saves it using 'php://output'.
On browser side, when I read through QNetworkReply's 'readAll()' function, some encoded string '��ࡱ�' gets printed and nothing gets saved in QFile object, totally empty file.
How do I get the desired excel file from this encoded string ?
Please, any help. It is Linux OS and I use LibreOffice if it matters.
Well, got the answer. I was printing QNetworkReply object's content on the console using reply->readAll() before reading it into the file and Qt documentation states that:
QNetworkReply is a sequential-access QIODevice, which means that once
data is read from the object, it no longer kept by the device.
Therefore, i ended up with an empty file. Found this when i printed the size of the 'reply' object. Also, found some eventLoop related help from here(Roozbeh's answer).
Hope it helps someone else as well. Thanks SO !

How to change an incorrect Mac file's Kind

I have several SQLITE files all of which have Kind set correctly to Document except for one which is Kind = Unix Executable file. It still loads and runs fine. I'd like to clean this up but can't find a way to change Kind for this file to Document.
Anybody know why Kind would have been set incorrectly in the first place and how to change it to the correct value? I've searched here and on Google.
Is there an extension (possibly hidden) set on the file? I think that 'Documents' are merely files without extensions. I'd try File>Get Info on it (via Finder) and checking to make sure there isn't a hidden extension in the 'Name & Extension'
I had the same issue with my php_error.log file. It was "document" and then I foolishly changed the "kind". That mean that the php log wouldn't work and my MAMP server didn't recognise it.
It's still "text document", but to fix the issue I opened up the file in TextEdit, selected "make rich text" under format, saved the file, closed it down, reopened it in TextEdit, selected "make plain text" under format, saved the file and it worked...

Getting extension of the file in FileUpload Control

At the moment i get file extension of the file like :
string fileExt = System.IO.Path.GetExtension(filUpload.FileName);
But if the user change the file extension of the file ( for example user could rename "test.txt" to "test.jpg" ), I can't get the real extension . What's the solution ?
You seem to be asking if you can identify file-type from its content.
Most solutions will indeed attempt the file extension, but there are too many different possible file types to be reliably identifiable.
Most approaches use the first several bytes of the file to determine what they are.
Here is one list, here another.
If you are only worried about text vs binary, see this SO question and answers.
See this SO answer for checking if a file is a JPG - this approach can be extended to use other file headers as in the first two links in this answer.
Whatever the user renames the file extension to, that is the real file extension.
You should never depend on the file extension to tell you what's in the file, since it can be renamed.
See "how can we check file types before uploading them in asp.net?"
There's no way to get the 'real' file extension - the file extension that you get from the filename is the real one. If file content is your concern, you can retrieve the content type using the .ContentType property and verify that it is a content type that you are expecting - eg. image/jpg.

Send file using Response.BinaryWrite() and delete it afterwards

As part of a Classic ASP Project the user should be able to download a file - which is dynamicly extracted from a zip archive and sent via Response.BinaryWrite() - by simply calling "document.asp?id=[some id here]".
Extracting and sending is not the problem but I need to delete the extracted file after the download finished. I never did any ASP or VBA before and I guess that's why I stuck here.
I tried deleting the file right after Response.WriteBinary() using FileSystemObject.DeleteFile() but this results in a 404-Error on the client-side.
How can I wait till the download finished and then do additional actions?
Edit: This is how my code looks like:
'Unzip a specified file from an archive and put it's path in *document*
set stream = Server.CreateObject("ADODB.Stream")
stream.Open
stream.Type = 1 ' binary
stream.LoadFromFile(document)
Response.BinaryWrite(stream.Read)
'Here I want to delete the *document*
I suspect that the point you are calling the DeleteFile method the file you are trying delete is currently locked by something else, the question is what?
Try including:-
stream.Close()
after your BinaryWrite. Also make sure you've done a similar thing to the component you've used to extract the file. If the component doesn't offer any obviouse "close" methods they trying assigning Nothing to the variables referencing them.
Is it not possible to stream the file into memory, then binary write the stream to the browser, this way the file is never created on the server and there is no need to delete it.
I found a solution: The extracted files are saved in a special directory and everytime a user runs the document.asp it checks this directory for files older than one hour and deletes them.
I think it's the simplest way to manage, but furthermore I would prefer a solution where the document is deleted after downloading.

Resources