SlickUpload
Welcome Guest Search | Active Topics | Log In | Register

Pass custom data from FileUploadStreamProvider to Upload controller Options
tomasr
#1 Posted : Wednesday, February 15, 2012 6:05:33 AM
Rank: Newbie

Groups: Registered

Joined: 2/15/2012
Posts: 5

I have sucesfully configured custom file provider like this

 

  <slickUpload>

    <uploadProfiles>

      <add name="pc">

        <uploadStreamProvider type="PC.CustomFileUploadStreamProvider, PC" location="~/CustomFileNameFiles" />

      </add>

    </uploadProfiles>

  </slickUpload>

 

Overided class like this

 class CustomFileUploadStreamProvider : FileUploadStreamProvider

    {

        public CustomFileUploadStreamProvider(UploadStreamProviderElement settings)

            : base(settings)

        {

        }

 

        public override string GetServerFileName(UploadedFile file)

        {

            var processId = Guid.NewGuid().ToString();

            var path = Path.Combine(PC.Settings.GetFileStoragePath, processId);

            Directory.CreateDirectory(path);

            var serverFileName = Path.Combine(path, file.ClientName);

            file.Data.Add("ProcessId", processId);            

            return serverFileName;            

        }

    }

 

and I would like to pass custom data to my upload controller(I am using MVC).

Please note the line 

file.Data.Add("ProcessId", processId);

But when I try to read UploadSession class in upload controller there is no my custom data. How to pass data from FileUploadStreamProvider to UploadSession?

 public class HomeController : Controller

    {

        public ActionResult Index(UploadSession session)

        {

//MyCode

}

}

 

tomasr
#2 Posted : Wednesday, February 15, 2012 8:08:54 AM
Rank: Newbie

Groups: Registered

Joined: 2/15/2012
Posts: 5
Found answer by myself, a custom data is under session.UploadedFiles.Data
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.