![云存儲文件上傳功能_第1頁](http://file4.renrendoc.com/view/571912894ab13df84afc8d1ffce303e2/571912894ab13df84afc8d1ffce303e21.gif)
![云存儲文件上傳功能_第2頁](http://file4.renrendoc.com/view/571912894ab13df84afc8d1ffce303e2/571912894ab13df84afc8d1ffce303e22.gif)
![云存儲文件上傳功能_第3頁](http://file4.renrendoc.com/view/571912894ab13df84afc8d1ffce303e2/571912894ab13df84afc8d1ffce303e23.gif)
![云存儲文件上傳功能_第4頁](http://file4.renrendoc.com/view/571912894ab13df84afc8d1ffce303e2/571912894ab13df84afc8d1ffce303e24.gif)
![云存儲文件上傳功能_第5頁](http://file4.renrendoc.com/view/571912894ab13df84afc8d1ffce303e2/571912894ab13df84afc8d1ffce303e25.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
文件上傳功能目錄21.技術(shù)原理2.效果圖預(yù)覽3.實(shí)現(xiàn)步驟4.功能驗(yàn)證測試技術(shù)原理3(1)視圖層:彈出文件上傳的操作界面(2)控制層:接收視圖層的消息,向服務(wù)層發(fā)送文件上傳參數(shù),并將服務(wù)層返回的結(jié)果發(fā)送到視圖層(3)服務(wù)層:調(diào)用swift提供的接口實(shí)現(xiàn)文件上傳,并將上傳結(jié)果返回給控制層功能描述4實(shí)現(xiàn)步驟5在cn/edu/sict/cloud/storage/service/SwiftStorageService.java添加如下代碼public
booleancreateFile(Stringusername,Stringpath,Stringname,Stringfilepath){SwiftDFSswiftdfs=newSwiftDFS();swiftdfs.createFile(username,path,name,filepath);return
true;}實(shí)現(xiàn)步驟6在cn/edu/sict/cloud/storage/sh/SwiftDFS.java添加如下代碼public
booleancreateFile(Stringrootpath,Stringpath,Stringname,Stringfilepath){if(path.equals("")){path=null;}else{path=path.substring(0,path.length()-1);}os.objectStorage().objects().put(rootpath,name,Payloads.create(newFile(filepath)),ObjectPutOptions.create().path(path));return
true;}實(shí)現(xiàn)步驟7在cn/edu/sict/cloud/storage/Web/StorageController.java添加如下代碼@RequestMapping("/uploadfile")@ResponseBodypublicObjectuploadfile(HttpServletRequestrequest,HttpServletResponseresponse,@RequestParam(value="qqfile",required=true)MultipartFilefile){try{if(!file.isEmpty()){byte[]bytes=file.getBytes();Stringupath=request.getSession().getServletContext().getRealPath("/");Stringuuid=UUID.randomUUID().toString();Stringpath="upload/"+uuid+file.getOriginalFilename();FileOutputStreamfos=newFileOutputStream(upath+path);fos.write(bytes);實(shí)現(xiàn)步驟8在cn/edu/sict/cloud/storage/Web/StorageController.java添加如下代碼fos.close();return
newMessageBean(true,Constants.SUCCESS_4,path);}else{return
newMessageBean(false,Constants.ERROR_6);}}catch(Exceptione){return
newMessageBean(false,Constants.ERROR_6);}}實(shí)現(xiàn)步驟9在cn/edu/sict/cloud/storage/Web/StorageController.java添加如下代碼@RequestMapping("/createfile")@ResponseBodypublicObjectcreatefile(HttpServletRequestrequest,HttpServletResponseresponse,Stringpath,Stringname,Stringfilepath){Useruser=getSessionUser(request);Stringupath=request.getSession().getServletContext().getRealPath("/");boolean
flag=false;flag=storage.createFile(user.getUsername(),path,name,upath+filepath);return
newMessageBean(flag,flag?Constants.SUCCESS_4:Constants.ERROR_5);}實(shí)現(xiàn)步驟10采用“fineuploader”控件實(shí)現(xiàn)文件上傳,特點(diǎn):(1)支持文件上傳顯示;(2)文件拖拽瀏覽器上傳方式;(3)Ajax頁面無刷新;(4)多文件上傳;(5)跨瀏覽器;(6)跨后臺服務(wù)端語言使用該控件需要引用js文件:<scriptsrc="assets/javascripts/fineuploader.js"></script>實(shí)現(xiàn)步驟11在main.jsp文件的js中添加如下代碼實(shí)現(xiàn)文件上傳functioncreateUploader(){varuploader=newqq.FineUploader({element:document.getElementById('result-uploader'),request:{endpoint:'uploadfile.action'},text:{uploadButton:'<iclass="glyphiconglyphicon-plus"></i>上傳文件'},實(shí)現(xiàn)步驟12在main.jsp文件的js中添加如下代碼實(shí)現(xiàn)文件上傳template:'<divclass="qq-uploader">'+'<preclass="qq-upload-drop-area"><span>{dragZoneText}</span></pre>'+'<divclass="qq-upload-buttonbtnbtn-defaultbtn-sm"style="background:#F6F6F6;border:1pxsolidrgb(206,206,206);display:inline;top:3px;padding:5px15px7px15px;width:100%;position:relative;overflow:hidden;border-radius:0;">{uploadButtonText}</div>'+'<spanclass="qq-drop-processing"style="display:none"><span>{dropProcessingText}</span>'+'<spanclass="qq-drop-processing-spinner"></span></span>'+'<ulclass="qq-upload-list"style="margin-top:10px;text-align:center;display:none"></ul>'+'</div>',實(shí)現(xiàn)步驟13在main.jsp文件的js中添加如下代碼實(shí)現(xiàn)文件上傳classes:{success:'alertalert-success',fail:'alertalert-error'},callbacks:{onComplete:function(id,fileName,responseJSON){if(responseJSON.success){varfielpath=responseJSON.other;createfile(fileName,fielpath);}}}});}實(shí)現(xiàn)步驟14在main.jsp文件的js中添加如下代碼實(shí)現(xiàn)文件上傳functioncreatefile(fileName,filepath){va
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度減肥健身器材銷售與服務(wù)合同
- 2025年度環(huán)境工程資料收集與評估合同范本
- 2025年度新型城鎮(zhèn)化建設(shè)安裝施工總承包合同
- 貴州2025年貴州省自然資源廳事業(yè)單位招聘14人筆試歷年參考題庫附帶答案詳解
- 邯鄲2024年河北邯鄲廣平縣招聘警務(wù)輔助崗位工作人員58人筆試歷年參考題庫附帶答案詳解
- 衡水2025年河北衡水職業(yè)技術(shù)學(xué)院招聘人事代理工作人員25人筆試歷年參考題庫附帶答案詳解
- 綿陽2024年四川省綿陽第一中學(xué)第三批招聘教師3人筆試歷年參考題庫附帶答案詳解
- 滁州安徽滁州天長市水利局機(jī)關(guān)綜合服務(wù)中心選調(diào)工作人員筆試歷年參考題庫附帶答案詳解
- 山西省卓越聯(lián)盟2024-2025學(xué)年高三下學(xué)期2月開學(xué)質(zhì)量檢測試題 地理 含答案
- 喹吖啶酮類項(xiàng)目融資計(jì)劃書
- 視頻監(jiān)控維保項(xiàng)目投標(biāo)方案(技術(shù)標(biāo))
- 2024標(biāo)準(zhǔn)版安全生產(chǎn)責(zé)任制培訓(xùn)記錄
- 中英旅游文本用詞的共同特點(diǎn)及其翻譯
- Meta分析的步驟與實(shí)例分析
- 城市區(qū)域環(huán)境噪聲監(jiān)測實(shí)驗(yàn)報告
- MBTI量表完整版本
- 護(hù)理操作-吸痰
- 中醫(yī)適宜技術(shù)-腕踝針
- 初二上勞動技術(shù)課件電子版
- 創(chuàng)業(yè)計(jì)劃書模板-創(chuàng)業(yè)計(jì)劃書-商業(yè)計(jì)劃書模板-項(xiàng)目計(jì)劃書模板-商業(yè)計(jì)劃書30
- 醫(yī)院護(hù)理帶教老師競聘課件
評論
0/150
提交評論