Blazor upload file issue - c#

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.

Related

Tamir SharpSSH sometimes constantly fails to download a file that is regularly pulled down by Filezilla

I am downloading files from a client's SFTP.
When I do it from Filezilla it always succeeds in the standard way.
On the other side, when I do it from our app, that uses Tamir SharpSSH library for SFTP communication, periods constantly emerge when our all download attempts for a file fail.
I know the app works as that code has not been changes for several months and it worked much more often then it did not, but the periods keep reemerging when for the whole day or more all file downloads fail only for the app.
The exception I get is Tamir.SharpSsh.jsch.SftpException . Obviously not very helpful.
My guess is the client is doing modifications on their side, or changing permissions, as their side is not live yet, but with the exception message I do not know.
Does anybody has some suggestion? Where could I look for the solution? What should I test/try?
Thank you for the time!
The real message was 'No such file'. The reason was, a slash has been omitted for the root folder path, in one of our config files.
When you open the exception variable in VS Watch you will see all info properties from standard exception are null or simply set to 'Tamir.SharpSsh.jsch.SftpException'.
But, an additional property was apparently added to Tamir.SharpSsh.jsch.SftpException class - "message" and that is where the real message is stored, while Exception.Message is pretty often set to just "Tamir.SharpSsh.jsch.SftpException" .
The issue is the additional property is private and is only visible by VS Watch or similar.
Since our exception propagation mechanism is based on logging Exception.Message I was most of the time getting "Tamir.SharpSsh.jsch.SftpException"

Downloading a file in C# incorrectly returns files that is zero bytes long

So I'm trying to Download a file using WebClient class but the problem is that when the download is finished the file that should be downloaded is 0 byte, I tried uploading the same file without extension and than changing it after download but that didn't help. What Can I do? This is the code I Use
WebClient updateDownloader = new WebClient();
updateDownloader.DownloadFile(new Uri("http://zazaia.ucoz.com/SomeExeFile.exe"),
Application.StartupPath + "\\SomeFile.EXE");
And also have DownloadCompleted event handler which just shows MessageBox and Disposes the WebClient.
There is nothing wrong with the code you have shown and this should work. The problem is on the server which is not returning the file properly. Also make sure that the site you are querying doesn't require some authentication before being able to download files. In addition to that don't forget that a WebClient will not execute any javascript, so if the server relies on it to download the file, this will not happen.
Have you checked that your antivirus is not interfering? Sometimes an automatic scan will lock an executable file being downloaded until it passes. The client code itself looks fine however.
What about the server side? If is one of your own applications serving the download, then it may not be setting the MIME header or even not handling the download correctly at all

How do I make WebClient.DownloadFile() work with xnb, xgs, xsb, xwb files?

I'm creating an Updater program in C# for my PC game that basically sends an Http message to the server to find out what the latest version of the game is. If there is a newer version, it downloads the necessary files. To download the files I used the WebClient.DownloadFile() method. There are a few posts on the forums detailing problems with this method but none of them are quite like mine.
I use the method like this:
WebClient webClient = new WebClient();<br/>
webClient.DownloadFile(sOriginFile, sDestinationFile);
I immediately ran into a problem downloading any files with the following extensions:
.xnb
.xgs
.xsb
.xwb
I would get an exception stating "The remote server returned an error: (404) Not Found."
So as an experiment I added 3, more common, files to the same directory.
.txt
.doc
.jpg
and the DownloadFile() method worked perfectly for those files. Does anybody know why this method isn't working for the first 4 files types but works fine with the last 3?
Also I tried WebClient.DownloadData() and HttpWebRequest.GetResponse() (after setting up the request), I even tried reversing the extension name on the server (.bnx), but no matter what, I would get the same exact exception.
If anybody really wants to tackle this, here are links to 2 sample files (I tried to post all 7 sample files but Stack Overflow only allows me to post 2 links):
http://www.facepuncher.com/Versions/CastleAbra/1.1/Sample.txt
http://www.facepuncher.com/Versions/CastleAbra/1.1/UiCursor.xnb
Most likely the MIME-Settings for the file types you mention are set up incorrectly in IIS. Go to IIS Server Mananger -> MIME-Settings and add the file-types accordingly.
Probably a better idea to transfer any filetype would be to download only files like
file.xnb.dat
file.xgs.dat
and rename them locally.
-Matthias

Can't delete a file from a client after uploading it to the server

I'm using asp:FileUpload control to upload a file to the server. Nothing fancy there, just
FileUploadId.Save();
File gets uploaded successfully, and everything is fine until I try to delete that file on the CLIENT. I get a good-old "File is being used by another person or program" message.
How do I make sure that file is not being accessed on the client after it's been uploaded?
EDIT
deleting the file has nothing to do with the application. i'm just trying to delete the file manually since i don't need it any more.
EDIT2
closing the browser fixed the problem ... any ideas?
Since the problem happens both in IE and FF: could it be that the file is locked by some AntiVirus software?
The issue might be the file can be locked by the aspnet process even after uploading. Once you close the IE, the aspnet process release the file
How are you trying to delete the file at the client? Unless you're hosting in WebBrowser, or using something like an ActiveX control, you only have javascript at the client - and that doesn't provide random file access.
So: what is the full setup here?
A thought. It may not be the file upload that is causing the problem. As the surrounding code isn't posted it's difficult to tell, but, for example, do you have a Zip manager object of some kind that you're not disposing of?

IIS Permissions for Saving Word Documents

Our ASP.NET/C# lets users edit and manage Word (OpenXML) documents that are hosted on a server. I am using client-side VBScript functions to handle some of the editing functions including saving the document to a folder on the server. For the save functionality, I am using the following function call :
Document.SaveAs "http://server/savefolder/savefile.docx"
I have given "Full Control" permissions on savefolder to both the NETWORK SERVICE and the IUSR_MACHINE users. Yet the above call fails. The error number returned is 5096. The error message is some gibberish that doesn't make any sense.
The server is Windows 2003 and the IIS version is 6.0. I have installed the OpenXML SDK 2.0 CTP on the server.
I can successfully read and print documents.
Does anyone tell me what I am doing wrong? or what additional settings need to be in place?
BTW, the error message ("gibberish" from my post) is:
"EOALPHABETICARABICARABICABJADARABICALPHABAHTTEXTCAPSCARDTEXTCHARFORMATCHI"
No, I am not making this up!
In my case, that error 5096 with description "EOALPHABETICARABICARABICABJADARABICALPHABAHTTEXTCAPSCARDTEXTCHARFORMATCHI"
occurred when using VBA code in Access to drive a Word mail-merge. The cause was trying to save a document with the same name (including path) as an open document.
Error line:
objApp.ActiveDocument.SaveAs saveAsName
where objApp is the object variable representing the Word application and saveAsName is the string variable storing the name I am trying to save the file as e.g. "C:\temp\testdoc.docx".
IF a file with the same name exists but is not open, the above code overwrites it silently.
Turns out WebDAV is not turned on by default in IIS 6.0. Once I turned it on, I was able to save the documents just fine.
Thanks for all your answers!
Just a guess... if the vbscript is running on the client, the code is probably running under the user's account, not under the server's IIS account. So unless you give write access to that user, vbscript probably won't work for this.
Since you're using ASP.NET, you could try writing a web service that takes in Word document data and saves it to the server for you.
I'd try running Fiddler on the client while trying to save the document to get a sense of what's really going on. I wonder if maybe it's trying to do an HTTP PUT (as opposed to a POST).
Have you given write access to the folder in IIS manager?
Is the save folder you're using outside of the websites root directory, i.e. 'hidden' from the internet?
Just to add to SI's information...
I also get this I get the 5096 - EOALPHABETICARABICARABICABJADARABICALPHABAHTTEXTCAPSCARDTEXTCHARFORMATCHI error when my code tries to save a MS Word document with the same name and to the same location as a Word document that is already open in another instance of Word.
Although not entirely relevant to this thread, I hope it may help someone else who stumbles upon this thread!
Regards,
Duane,
this question is old but still active ?
You save the file with a http://... url, i think you should save it with a file URL as
Document.SaveAs "\\server\savefolder\savefile.docx"
Grtz

Categories

Resources