Ejemplo n.º 1
0
        public async Task <ActionResult> UploadFile([FromForm] IFormFile file,
                                                    [ModelBinder(BinderType = typeof(JsonModelBinder))]
                                                    TorrentControllerUploadFileRequest formData)
        {
            if (file == null || file.Length <= 0)
            {
                throw new Exception("Invalid torrent file");
            }

            var fileStream = file.OpenReadStream();

            await using var memoryStream = new MemoryStream();

            await fileStream.CopyToAsync(memoryStream);

            var bytes = memoryStream.ToArray();

            await _torrents.UploadFile(bytes, null, formData.AutoDownload, formData.AutoUnpack, formData.AutoDelete);

            return(Ok());
        }
Ejemplo n.º 2
0
 public async Task TorrentsAddFile(Byte[] fileBytes, Boolean autoDownload, Boolean autoDelete)
 {
     await _torrents.UploadFile(fileBytes, autoDownload, autoDelete);
 }
Ejemplo n.º 3
0
 public async Task TorrentsAddFile(Byte[] fileBytes, String category, Boolean autoDownload, Boolean autoUnpack, Boolean autoDelete)
 {
     await _torrents.UploadFile(fileBytes, category, autoDownload, autoUnpack, autoDelete);
 }