在AmazonS3直接上传表单POST额外的输入字段 [英] Extra Input fields in AmazonS3 Direct Upload POST Form

查看:102
本文介绍了在AmazonS3直接上传表单POST额外的输入字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的文章的形式增加了一个额外的标题字段,在我的模型创造了一个title属性。的视频已上传之后,服务器被引导到另一控制器。这是通过设置在策略文件重定向场完成。现在我怎么可以访问重定向器标题字段?

I have added an extra "title" field in my POST form and created a "title" attribute in my model. After the video has been uploaded the server is directed to another controller. This is done by setting the redirect field in the policy file. Now how can I access the title field in the redirected controller?

在POST形式:

<form action="@Model.FileUploadModel.FormAction" method="@Model.FileUploadModel.FormMethod" enctype="@Model.FileUploadModel.FormEnclosureType" >

                     <input type="hidden" name="key" value="@Model.FileUploadModel.FileId" /> 
                     <input type="hidden" name="AWSAccessKeyId" value="@Model.FileUploadModel.AWSAccessKey" /> 
                     <input type="hidden" name="acl" value="@Model.FileUploadModel.Acl" /> 
                     <input type="hidden" name="policy" value="@Model.FileUploadModel.Base64EncodedPolicy" /> 
                     <input type="hidden" name="signature" value="@Model.FileUploadModel.Signature" /> 
                     <input type="hidden" name="redirect" value="@Model.FileUploadModel.RedirectUrl" /> 
                     <div class="row">  
                            **<label for="Title" style="padding-right: 5px;">Title (optional) </label>
                            <input type="text" name="Title"  style="width: 200px;" />**
                     </div>
                     <div class="row_clear"></div>
                     <div class="row">
                             <input type="file" name="file" size="100" id="file"/> 
                     </div>
               </form>

和我FileUploadModel

and my FileUploadModel

    public FileUploadModel(string publicKey, string privateKey, string bucketName, string redirectUrl)
    {
        myPrivateKey = privateKey;

        FormAction = string.Format("https://{0}.s3.amazonaws.com/", bucketName);
        FormMethod = "post";
        FormEnclosureType = "multipart/form-data";
        Bucket = bucketName;
        FileId = "u5/i/" + Guid.NewGuid().ToString(); 
        AWSAccessKey = publicKey;
        Acl = "private"; 

      RedirectUrl = redirectUrl;
    }
    public string FormAction { get; private set; }
    public string FormMethod { get; private set; }
    public string FormEnclosureType { get; private set; } 
    public string Bucket { get; private set; }
    public string Acl { get; private set; }
    public string Policy { get; private set; }
    public string FileId { get; private set; }
    public string AWSAccessKey { get; private set; }
    public string RedirectUrl { get; private set; }
    [Display(Name = "Title (optional)")]
    public string Title { get; set; }
    [Display(Name = "File")]
    public HttpPostedFileBase File { get; set; }
    public int? Page { get; set; }
    public string SearchString { get; set; }

}

}

下面是我提到的创建策略表的链接。

Here is the link I referred for creating policy form.

<一个href="http://$c$conaboat.word$p$pss.com/2011/04/22/uploading-a-file-to-amazon-s3-using-an-asp-net-mvc-application-directly-from-the-users-browser/"相对=nofollow>链接

推荐答案

我通过发送通过URL标题属性合作解决该问题。

I worked around the problem by sending the title attribute through the URL.

在我RouteConfig文件,我添加了一个新的路径:

In my RouteConfig file I added a new route:

 routes.MapRoute(
                name: "Transcode",
                url: "{controller}/{action}/{title}/{id}",
                defaults: new
                {
                    controller = "Videos",
                    action = "Transcode",
                    id = UrlParameter.Optional
                }
            );

然后在跨code动作我加了一个标题参数。然后,我终于传递到重定向URL属性的值是:的http://开发.area.local /视频/跨code /标题

这篇关于在AmazonS3直接上传表单POST额外的输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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