Skip to content

Conversation

@anomal3
Copy link

@anomal3 anomal3 commented Apr 2, 2024

Hey)) Unfortunately you do not have a separate branch. And I also ask you to consider a method that allows you to download files not only via a link, but also to be able to download files locally. In my approach, this comes in handy because I scan from Lidar and upload files to the server, and then I can view them using the 3D viewing tool.

This method works through a controller to which we pass the path to the file on the local disk

[Route("api/[controller]")]
[ApiController]
public class FileController : Controller
{
    /// <summary>
    /// Addition as a controller for accessing local files
    /// </summary>
    /// <param name="link">Full path local file</param>
    /// <returns></returns>
    [HttpGet("[action]")]
    public IActionResult FileDownload([FromQuery] string link)
    {
        var saveFileName = link.Substring(link.LastIndexOf('\\') + 1);
        try
        {
            var fileBytes = System.IO.File.ReadAllBytes(link);
            var contentType = "APPLICATION/octet-stream";
            var fileName = saveFileName;
            return File(fileBytes, contentType, fileName);
        }
        catch (Exception ex)
        {
            return StatusCode(StatusCodes.Status500InternalServerError, "Error download: " + ex.Message);
        }
    }
}

LocalLoad

Copy link
Author

@anomal3 anomal3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How long are wait?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant