I have a web app that needs to convert PDFs to XODs (PDFTron’s format to display documents in their WebViewer). My Web App is hosted on Azure, the PDFs are on Azure Storage. We would like to go along with the on-premises conversion via PDFNet SDK (http://www.pdftron.com/webviewer/getstarted.html, see “Choosing a deployment model for conversions), my code so far is the following: 

WebRequest req = HttpWebRequest.Create("url of PDF on Azure Storage here");                         
using (Stream stream = req.GetResponse().GetResponseStream())
{
    PDFDoc pdfdoc = new PDFDoc(stream);
    var converted = pdftron.PDF.Convert.ToXod(pdfdoc);
    //pdfdoc.Save(stream, pdftron.SDF.SDFDoc.SaveOptions.e_linearized); //not clear to me
}


My approach here is to create a stream from the file on azure storage and convert that stream to XOD. I still don’t know if I should call “Save” and in that case where the file would be saved.
My questions are:


Since everything runs on the cloud does it make sense to use the CloudAPI instead of the self-hosted solution or does it not make any difference?
In both cases, where is the converted file stored (since I am getting it from the Azure storage and not from a local server), since I would then need to move it to my azure storage account. Does the file get saved locally (meaning on the web/worker role which is processing it) and therefore needs to be moved to the storage?


Here (http://www.pdftron.com/pdfnet/samplecode.html) there are conversion code samples but they all use files on local machine, which would not be my case. 


Question: How does emulated storage actually work?
Answer: This does not depend on stock Android, it depends on Xiaomi. Your system is only installed in a partition (system), it does not alterate the whole partition table on your device.

I had the same problem with my MI2S. Only recently I repartitioned the whole phone, giving 10 gigs to the apps' section. It seems like it's the only way. Here are the detailed instructions.

http://xiaomi.eu/community/threads/mi2s-extending-size-of-storage-partition.21391/

Obviously you have to do the opposite, as stillka is removing space from the data partition to give it to the storage one. Giving that you basically have to delete both partitions and recreate them with different size, the procedure is the same, you just have to make your own calculations as you have to give startpoint and endpoint, not size.

I did this procedure twice in a row, because the first time I also removed system1 partition to get another 500 MBs, and I didn't brick my phone nor the first neither the second time so, even if the procedure looks scary it is quite safe. Obviously it means losing every single data you have in your phone, both apps and such and personal data. So, you must use some backup app to save your apps and data and then copy the whole sdcard (including the backup you just did) to your PC, restoring once you recreate the partitions.

Note about chache and system1: you can also delete these partitions (really, shrink them to 3 MB - the minimum to make them ext4 filesystem - as you shouldn't change the original partition table) to gain even more space, but there are consequences.

Cache: some people say this partition is used by Google's Play Store to temporarily store (pardon the play on words) apks files before installing the app to your phone. That means, if you remove it you won't be able to install apps from there anymore, and if you shrink it too much you will be able to instal small apps only. If you use other sources than the Play Store (or, maybe, even Xiaomi's official market) you should be good.

System1: this is for the fake dual boot MIUI uses: every time you update your system through the built-in Updater app, the new ROM is written to the system you were not in, alternating between the two at every update. This is to have a correctly functioning system in your phone, not overwriting the previous system while updating (so, it is like a system backup). If you remove it, you won't be able to use the Updater app anymore, you should every time flash the newer ROM when you want to update. I did not do this as I use MI2S' Sepcial Edition MIUI 6 ROM, and the only easy way to install it without third party tools is install the egular v5 ROM and update with the Updater app. Your choice.