<commit_before>using System;
using System.IO;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using FormFactory.ValueTypes;

namespace FormFactory.Mvc.UploadedFiles
{
    public class AppDataFileStore : IFileStore
    {

        public UploadedFile Store(HttpPostedFileBase httpPostedFileBase, ControllerContext controllerContext, ModelBindingContext modelBindingContext)
        {
            var dir = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/UploadedFiles");

            Directory.CreateDirectory(dir);
            var directoryName = Guid.NewGuid().ToString();
            var relativePath = Path.Combine(directoryName, Path.GetFileName(httpPostedFileBase.FileName));
            var fullPath = Path.Combine(dir, relativePath);
            Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
            httpPostedFileBase.SaveAs(fullPath);

            var uploadedFile = new UploadedFile()
            {
                ContentLength = httpPostedFileBase.ContentLength, ContentType = httpPostedFileBase.ContentType, FileName = Path.GetFileName(relativePath), Id = directoryName
            };
            var serializer = new JavaScriptSerializer();
            var metadata = serializer.Serialize(uploadedFile);
            File.WriteAllText(Path.Combine(StoreFolderPath, uploadedFile.Id, "metadata.json"), metadata);
            return uploadedFile;
        }

        public UploadedFile GetById(string id)
        {
            var serializer = new JavaScriptSerializer();
            var filename = Path.Combine(StoreFolderPath, id, "metadata.json");
            var uploadedFile = serializer.Deserialize<UploadedFile>(File.ReadAllText(filename));
            uploadedFile.SetGetStream(() => File.OpenRead(Path.Combine(StoreFolderPath, id, uploadedFile.FileName)));
            return uploadedFile;
        }

        private static string StoreFolderPath
        {
            get { return System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/UploadedFiles"); }
        }
    }
}<commit_msg>Add GetStream to initial UploadedFile<commit_after>using System;
using System.IO;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using FormFactory.ValueTypes;

namespace FormFactory.Mvc.UploadedFiles
{
    public class AppDataFileStore : IFileStore
    {

        public UploadedFile Store(HttpPostedFileBase httpPostedFileBase, ControllerContext controllerContext, ModelBindingContext modelBindingContext)
        {
            var dir = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/UploadedFiles");

            Directory.CreateDirectory(dir);
            var directoryName = Guid.NewGuid().ToString();
            var relativePath = Path.Combine(directoryName, Path.GetFileName(httpPostedFileBase.FileName));
            var fullPath = Path.Combine(dir, relativePath);
            Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
            httpPostedFileBase.SaveAs(fullPath);

            var uploadedFile = new UploadedFile()
            {
                ContentLength = httpPostedFileBase.ContentLength, ContentType = httpPostedFileBase.ContentType, FileName = Path.GetFileName(relativePath), Id = directoryName
            };
            var serializer = new JavaScriptSerializer();
            var metadata = serializer.Serialize(uploadedFile);
            File.WriteAllText(Path.Combine(StoreFolderPath, uploadedFile.Id, "metadata.json"), metadata);

            uploadedFile.SetGetStream(() => File.OpenRead(Path.Combine(StoreFolderPath, uploadedFile.Id, uploadedFile.FileName)));

            return uploadedFile;
        }

        public UploadedFile GetById(string id)
        {
            var serializer = new JavaScriptSerializer();
            var filename = Path.Combine(StoreFolderPath, id, "metadata.json");
            var uploadedFile = serializer.Deserialize<UploadedFile>(File.ReadAllText(filename));
            uploadedFile.SetGetStream(() => File.OpenRead(Path.Combine(StoreFolderPath, id, uploadedFile.FileName)));
            return uploadedFile;
        }

        private static string StoreFolderPath
        {
            get { return System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/UploadedFiles"); }
        }
    }
}
{'fraction_non_alphanumeric': 0.09097270818754374, 'fraction_numerical': 0.0, 'mean_word_length': 3.0112254443405053, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6980168', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1070, 'n_words': 202}