0

I'm trying to make an ASP.NET 5 API that has a "Video" entity with four attributes:

    public class Video
    {
        public Guid VideoId { get; set; }
        public string Description { get; set; }
        public long SizeInBytes { get; set; }
        public string ContentPath { get; set; }
    }

My questions are two:

  1. Is it possible to store locally (in a folder in the solution) the file located in the path entered via POST REQUEST in the attribute ContentPath? If so, what is the easiest way to do this?

  2. Is it possible that the attribute SizeInBytes is automatically set according to the size of the file located in the ContentPath?

  • Are you trying to *upload* a file to a controller? Or something else? It's not really clear to me what specifically you're asking or what isn't working as expected. – David Oct 22 '21 at 12:38
  • 1) Please elaborate what you mean. If I understand correctly you want to save it in a folder in your project then yes you can easily create a folder inside VS and add your file by using add existing file menu. 2) Yes, it's a property you can add a method to set (set section of property) which will change the value of SizeInBytes when ever the value of ContentPath is changed. – Afshin Mobayen Khiabani Oct 22 '21 at 12:41
  • I would like to insert a URI attribute string ```ContentPath``` via POST REQUEST, and have the file located at that URI uploaded to a folder in the solution. So yes, in a way I need to upload a file to the controller. And so far nothing is working, as I don't even know if it can be done. – Matheus Reis Oct 22 '21 at 12:43
  • That means you want to download a file from other URI; Not upload it. Check download methods in this site. – Afshin Mobayen Khiabani Oct 22 '21 at 12:45
  • @MatheusReis: If you're inputting a URL to your application and you want your application to fetch the file at that URL then what you're asking is to *download* that file. Which would explain why you're struggling to find examples of how to do that, since you're using the wrong terminology. In that case this may now be a duplicate of [this question](https://stackoverflow.com/q/307688/328193). – David Oct 22 '21 at 13:00

0 Answers0