using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sphorium.WebDAV.Server.Framework.BaseClasses;
using Everest.CmsServices.Services;
using Everest.Library;
using Everest.CmsServices.Models;
using System.Collections.Specialized;
using System.IO;
using Everest.CmsServices.MvcHelper;
namespace Everest.CmsServices.Rfc.WebDAV{
public class DavGet : DavGetBase
{
public DavGet()
{
this.ProcessDavRequest += new DavProcessEventHandler(DavGet_ProcessDavRequest);
}
private void DavGet_ProcessDavRequest(object sender, EventArgs e)
{
WebDavUrlData urlData = new WebDavUrlData(WebDavHelper.GetRawHostUrl(HttpApplication.Request), RelativeRequestPath);
//BinaryContentService binaryContentService = UnityManager.Resolve<BinaryContentService>();
//var folder = CachedData.GetFolder(urlData.Application, urlData.FolderName);
ContentService contentService = new ContentService(urlData.Application);
var content = contentService.SetQueryType(Everest.CmsServices.Providers.QueryType.All).GetBinaryContentByUserKey(urlData.ContentKey, null);
if (content != null)
{
string filePath = HttpApplication.Server.MapPath(content["FilePath"].ToString());
if (File.Exists(filePath))
{
FileInfo _fileInfo = new FileInfo(filePath);
using (FileStream _fileStream = _fileInfo.OpenRead())
{
long _fileSize = _fileStream.Length;
byte[] _responseBytes = new byte[_fileSize];
_fileStream.Read(_responseBytes, 0, (int)_fileSize);
base.ResponseOutput = _responseBytes;
_fileStream.Close();
}
}
return;
}
base.AbortRequest(ServerResponseCode.NotFound);
}
}
}
|