ASP.net MVC文件上传到Amazon S3与进步 [英] ASP.net MVC file upload to Amazon S3 with progress

查看:219
本文介绍了ASP.net MVC文件上传到Amazon S3与进步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我有一个ASP.net MVC应用程序需要将文件上传到Amazon S3与进步。我发现了一个叫Flajaxian整洁的控制,没有工作pretty好。问题是,现在我要插入一行数据成保持跟踪上传的DB。如果你看一下控制低于code的上传完成后,将触发一个事件FileUploader1_ConfirmUpload。 Url.Action(上传,TracksController)不会做什么我想它,这是火在TrackController控制器上传操作。这是我第一次与MVC的工作,所以我希望有一个简单的解决方案。

I have a ASP.net MVC app that needs to upload files to Amazon S3 with progress. I found a neat control called Flajaxian that does the job pretty well. The issue is that now I want to insert a row of data into a DB that keeps track of the uploads. If you look at the code below the control has a FileUploader1_ConfirmUpload event that fires after the upload has completed. Url.Action("Upload", "TracksController") does not do what I want it to, which is fire the Upload Action in the TrackController Controller. This is the first time I've worked with MVC so I'm hoping there is a simple solution.

我本来有一个提交按钮,在code这样执行上传< D​​IV CLASS =submitBtnDiv><输入类型=提交值=提交级=submitBtnID =trackAdd/>< / DIV> 。但现在上传的是异步的,所以我希望做同样的回发

I originally had a submit button to perform the upload in code like this <div class="submitBtnDiv"><input type="submit" value="Submit" class="submitBtn" id="trackAdd" /></div>. but now the upload is asynchronous so i want to do the same postback

感谢您给大家,需要的时候通过这个阅读,更对那些试图解决这个问题。

Thank you to everyone that takes the time to read through this, and even more to those that try to solve it.

 <div class="contentsAcc"><form id="form2" runat="server" style="width:400px">
                <script runat="server">
                    private void FileUploader1_FileNameDetermining(object sender, FileNameDeterminingEventArgs e)
                    {
                        e.FileName = SessionWrapper.PersonId.ToString() + "_" + e.FileName;
                    }
                </script>
                <script runat="server">
                    private void FileUploader1_ConfirmUpload(object sender, ConfirmUploadEventArgs e)
                    {
                        Url.Action("Upload", "TracksController");                            
                    }
                </script>
                    <fjx:FileUploader ID="FileUploader1" runat="server">
                        <Adapters>
                            <fjx:DirectAmazonUploader   OnFileNameDetermining="FileUploader1_FileNameDetermining" OnConfirmUpload="FileUploader1_ConfirmUpload"
                                AccessKey="WebConfig:AmazonAccessKey" 
                                SecretKey="WebConfig:AmazonSecretKey"
                                BucketName="tracksupload" />
                        </Adapters>
                    </fjx:FileUploader>

        </form></div>

好了,我已经尽力了一下从昨天上述改变我的做法。而不是试图火TracksController的行动我想给行动code搬进Confirm_Upload事件。但现在我还需要获得文本框的值。由于MVC犯规记得状态,它被证明是困难的。下面是文本框。它们是相同的页面,作为code上方。

Ok, so I've tried to change my approach a bit from the above yesterday. Instead of trying to fire the Action of the TracksController i want to move that Action code into the Confirm_Upload event. But now I still need to get the values of the textboxes. Because MVC doesnt remember state it is proving difficult. Here are the textBoxes. they are on the same page as the code above.

 <label for="BandName">Artist</label> 
       <%=Html.TextBox("Artists") %><%:Html.ValidationMessage("Artist","*")%>
        <div class="clearfix">
        </div>
        <label for="SongName">Song Title
        </label>
          <%=Html.TextBox("SongName") %><%:Html.ValidationMessage("SongName","*")%>
        <div class="clearfix">
        </div>

是否有可能拉文本框的值,并将它发送到发生服务器端Confirm_Upload事件?如果不能与服务器code,那么也许JavaScript客户端?

Is it possible to pull the values of the textbox and have it sent to the Confirm_Upload event which happens server side? If not with server code then maybe JavaScript client side?

使用上载控制IM是不excatly我想要的只有一个,但它是网页形式,该网站是MVC。所以我有一个MVC页面上的Web窗体控件。我想使用MVC文本框的值,并将其传递到Web表单控制处理。

推荐答案

Url.Action只返回一个URI。你是不是想重定向?

Url.Action simply returns a URI. Are you trying to redirect?

有时WebForms的事件在MVC工作,所以我看到,如果它是你需要重定向一样简单。

Sometimes WebForms events work in MVC so I was seeing if it was as simple as you needing to redirect.

您的主要问题是你要使用的WebForms code在什么看起来像一个MVC页面。这主要是不相容的,你需要自己直接在您的视图wireup JavaScript或使用许多其他JavaScript文件上传控件。

Your main problem is you are trying to use WebForms code in what looks like a MVC page. This is mostly incompatible and you'll need to wireup javascript yourself or use another of the many javascript file upload controls directly in your view.

由于我不熟悉的S3上传我不能推荐任何东西。也许其他SO用户可以回答好。

I can't recommend anything because I'm not familiar with S3 uploading. Maybe another SO user can answer better.

这篇关于ASP.net MVC文件上传到Amazon S3与进步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆