1.配置环境
项目中引用 QiNiu.4.0.dll
在webconfig: <add key="USER_AGENT" value="qiniu csharp-sdk v6.0.0"/> <add key="ACCESS_KEY" value=""/>//账号 ---> 密钥AK <add key="SECRET_KEY" value=""/>//账号 ---> 密钥SK <add key="RS_HOST" value="http://rs.Qbox.me"/> <add key="UP_HOST" value="http://up.qiniu.com"/> <add key="RSF_HOST" value="http://rsf.Qbox.me"/> <add key="PREFETCH_HOST" value="http://iovip.qbox.me"/> <add key="API_HOST" value="http://api.qiniu.com"/>
2.创建七牛文件的实体类 public class QiNiuFile{ public string fileUrl { get; set; } public string fileKey { get; set; } public string fileMime { get; set; } public string fileThumbnailUrl { get; set; } }
3.页 面Html 用的form 提交 <style type="text/css"> .c-list { color: #000; margin: 0 0 0 10px; }
.text-none { display: none; }
.text-block { display: block; }
.td1 { background-color: Silver; }
.inputFile { display:none; }
.opacity { filter:alpha(opacity=50); /*IE滤镜,透明度50%*/ -moz-opacity:0.5; /*Firefox私有,透明度50%*/ opacity:0.5; /*其他,透明度50%*/ }
#fileList .file { margin: 10px; width: 80px; height: 80px; float: left; }
#fileList .file div { margin-left: auto; margin-right: auto; }
#fileList .file .flieKey { width: 60px; height: 60px; }
#fileList .file .flieKey img { width: 60px; height: 60px; }
#fileList .file .fileName { text-align: center; }
#loadSta { position:absolute; left:0px; top:0px; width:100%; height:100px; z-index:99; filter:alpha(opacity=50); vertical-align:middle; text-align:center; display:none; } #loadSta img { margin-top:200px; }
</style> <form ,vframe,offset,width,height);
string ThumbnailUrl = GetFileUrl(fileKey, true, domain) + thumbnail; return ThumbnailUrl; }
/// <summary> /// 初始化七牛,读取webconfig /// </summary> public static void InitQiniu() { Qiniu.Conf.Config.Init(); }
} }
|
请发表评论