I am working with Store apps using C#.
I am using StorageApplicationPermissions.MostRecentlyUsedList to load Local Epub files.
After getting those file as a Storage file.
string EpubPathToken= Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList.Add(file);
StorageFile file = await StorageApplicationPermissions.FutureAccessList.GetFileAsync(EpubPathToken);
Extraction(file);
While Extracting the Epub file as Zip to Package folder using ApplicationData I am getting an Exeption of Unauthorized.
Here's screen shot of error
Why because If I use the same code using from KnownFolders like Pictures Library the Extraction is working Fine.
Can any one give me any idea about this ?
Finally I solved the issue of getting exception of Unauthorized With the use of Blog
I changed the code snippet according to my requirement.
The source of code describes writes bytes of file in ZipArchiveEntry,
hence I used a helper method GetByteFromFile(), which takes StorageFile object and returns me byte[] array.
Finally thanks to Xyroid
Related
I'm writing a blazor server app that will sit in the adobe marketplace
I want to upload a file through the app and place it on a server
When I call the standard code for uploading a file , I get the following exception
'''
FileStream fs = File.Create(path);
await file.OpenReadStream().CopyToAsync(fs);
fs.Close();
'''
"An error occurred while reading the remote stream: TypeError: r.arrayBuffer is not a function"
I iBrowserFile onjetc has data and I can create a buffer with the correct bytes
I can create a placeholder on the server but cannot add the stream to the path Ive created
if I run the app outside of adobe , it uploads just fine
I cant find anything related to this error , is there any other way to upload a file ?
This may not fully answer your question, but a related GitHub issue indicates a low RAM issue. In my case, this issue was present on older iPads but newer iPads did not have this issue. As this happens over SignalR, this is most likely lack of browser support for handling the file.
My only solution I could find was to not support the old version of iOS that is causing this.
I have the following scenario in my UWP App:
The user imports a file (e.g. using a FilePicker, or by dragging a file onto the app, etc.) into my application.
We save some metadata of this file inside our internal database, and we also save a token retrieved using the following code:
string token = StorageApplicationPermissions.FutureAccessList.Add(file);
The user closes the app.
The user re-opens the app.
Now we want to overwrite the initial file. To do this, we retrieve the StorageFile using this code:
StorageFile exportTarget = await StorageApplicationPermissions.FutureAccessList.GetFileAsync(token);
but when I try to write into the file, e.g. using
using (IRandomAccessStream fs = await exportTarget.OpenAsync(FileAccessMode.ReadWrite))
I get an exception complaining that exportTarget is ReadOnly.
How can I have access to such file in Write mode?
It turned out it was not a strict problem of the StorageApplicationPermissions.FutureAccessList.
The problem happens in fact only if the user imports a file by dragging-and-dropping the file into the app: in this case, the DataPackageView.GetStorageItemsAsync() method returns a list of StorageFile that are ReadOnly.
So, the only way to overwrite those files is by using PathIO methods, as described in this post: https://github.com/microsoft/microsoft-ui-xaml/issues/2421
How to load Dicom image from server (path contains https://)
Am using fo-Diocm library.
var image = new DicomImage(filePath);
if filePath is from local directory its working fine.
if filePath is from server (like https://example.com/filepath.dcm), its throwing 'Dicom.DicomFileException' saying that specified path value is not correct.
What is the right way to load DicomImage from server ??
AFAIK: Not at all. Obtaining DICOM Files through Web API is referred to as WADO (Web Access to DICOM Objects), and there is an open feature request in fo-dicom to support this, but it has been assigned quite a high priority.
However, the URL https://example.com/filepath.dcm does not adhere to WADO encoding, so maybe you cannot use a DICOM communication protocol to obtain the image (or you do not want to). But in this case, your task is simply "downloading a file from an URL" and not related to DICOM at all. After the download is completed, you have it stored locally, and can go on with local file access as you are used to.
The "missing link": How to download a file from an URL
I tried to use few method to download 1 excel file from website
I tried to use WebClient and DownloadFile... but it return 400 bad
request
I tried to use File.WriteAllBytes also kick in exception
My current workaround is call IExplorer with that particular file path ..then it will start to download(after user select file path)
Is that any way that i can straight download excel file without any notification?
Sample Excel Link: https://example.com/sr/XXX.issueviews:searchrequest-excel-all-fields/12345/SearchRequest-12345.xls?tempMax=1000
I'm having an issue downloading a file. I'm running this website on my local IIS. The BaseUrl correctly has the address of my local IIS site. The moduleImgPath is a Sitecore media item: "/sitecore/shell/~/media/Racking/module-image.png". The BaseUrl has the structure "http://local-$company.com".
The code used for the download is essentiall shown below. The method errors on Image.FromStream() with a System.ArguementException - "Parameter is not valid."
Stream stream = new MemoryStream(new WebClient().DownloadData(RackingConfigHelper.BaseUrl + moduleImgPath));
Image objImage = Image.FromStream(stream);
My question essentially revolves around - can you use a WebClient this way, to download data from what essentially a local source? Or will I need to deploy this code to my test environment to test it out? If I can, do I need to worry about ports?
It looks like your image data is not a jpg (I think this is typically what is expected for Image).
You can see why the error happens on this msdn link
and you can see the docs for Image on this msdn link
I would hazard a guess you are either trying to use a non-jpg OR perhaps the jpg you have may be unusually formed.