question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(500) Internal server error on deleting files

See original GitHub issue

I am unable to delete the 6 files that tus creates when for each uploaded file. I am pretty much using the TusClient and TusHttpClient from Tus.io

On the odd occasion it does actually delete the files but 95% of the time I get an internal server error.

2019-07-30 12:15:54.1926 ERROR [8:] TusFileTransferClient.TusHttpClient.PerformRequest TusException : TusFileTransferClient.TusException: The remote server returned an error: (500) Internal Server Error. —> System.Net.WebException: The remote server returned an error: (500) Internal Server Error. at System.Net.HttpWebRequest.GetResponse()

var file = new FileInfo(filename);
var client = new TusClient();
var metaData = new Dictionary<string, string>
{
   {"product", _fileRetrievalInfo.DisplayName},
   {"fileType", _fileRetrievalInfo.RetrievalType.ToString()}, 
   {"id", _surveyor.Id.ToString()}
};
var fileUrl = client.Create(uploadAddress, file, metaData);
client.Upload(fileUrl, file);
client.Delete(fileUrl));
''''

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
Unthredcommented, Aug 22, 2019

So whilst I have not managed to get a proper error message I have found the cause. It was obviously me being a dufus!

So in this code to save the uploaded file

using (var output = new FileStream(localFilename, FileMode.Create))
{
   var uploadedFile = await file.GetContentAsync(token);
   Log.Debug($"---> Received uploaded file, CopyTo {localFilename}");
   uploadedFile.CopyTo(output);
   await output.FlushAsync(token);
   output.Close();
   uploadedFile.Close();   <-----
}

I had forgotten to close the file.

Perhaps some error checking around the file deletion so it can give a better error message for idiot users like me?

Thanks for all your help it works perfectly now

1reaction
Unthredcommented, Aug 20, 2019

I haven’t as yet I am afraid I was dragged off the project for a week or so. I am back on it now and will try tomorrow to get the logs. The project I am working on is using asp.net and mvc 5 so will have to work out how to get global error handlers for it as I believe its not as easy as core.

I have however found that sometimes it does delete the files without errors, not often but sometimes. I suspect something is keeping the file open or some such.

Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't delete or move empty folder: 500 Internal Server Error
I have discovered a couple of folders in my nextcloud account that can not be deleted or moved. For at least one folder...
Read more >
How to Fix a 500 Internal Server Error on Your Site
The 500 Internal Server Error status code occurs when the server encounters an error that prevents it from fulfilling the request.
Read more >
What is “HTTP 500 Internal Server Error” and How to Fix It?
A common cause of the “Internal Server Error” is a problem within the .htaccess file. If the file is corrupted, it defines an...
Read more >
HTTP 500 Internal Server Error: What It Means & How to Fix It
If You're Trying to Load a Page with a 500 Internal Server Error: · 1. Refresh the page. · 2. Come back later....
Read more >
How to Fix a 500 Internal Server Error
In most cases, a 500 Internal Server Error is due to an incorrect permission on one or more files or folders. In most...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found