using System;
using System.Net.Http;
using System.Net.Http.Headers;

namespace DeviceRepair.Api.Common
{
    public class DoMultipartFormDataStreamProvider : MultipartFormDataStreamProvider
    {
        public DoMultipartFormDataStreamProvider(string rootPath) : base(rootPath) { }

        public override string GetLocalFileName(HttpContentHeaders headers)
        {
            string fileName = headers.ContentDisposition.FileName.Trim('\"');
            string newFileName = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(fileName);
            return newFileName;
        }
    }
}