2015-04-02 39 views
0

訪問文件系統文件夾我上傳一些文件到uploadFolder C:/上傳配置路徑如何Grails的

environments { 
    development { 
     uploadFolder = "C:/upload/" 
    } 
    production { 
     uploadFolder = "C:/upload/" 

    } 
    test { 
     uploadFolder = "C:/Users/" 
    } 
} 

,我把它存儲在控制器

documentInstance.fullPath = grailsApplication.config.uploadFolder + documentInstance.filename 

如何訪問Grails中C:/ upload/file中的文檔?

+0

所有的文件,問題是....? – injecteer 2015-04-02 21:52:58

+0

如何訪問Grails中C:/ upload/file中的文檔? @injecteer – Mozein 2015-04-03 01:10:26

回答

0

您在Grails中訪問文件的方式沒有任何差異,然後在普通Web應用程序中如何執行。如果你的路徑是絕對路徑,你可以像這樣

def path = grailsApplication.config.uploadFolder + documentInstance.filename 
File file = new File(path) 

,或者列出文件夾上傳

Folder dir = new File(grailsApplication.config.uploadFolder) 
dir.eachFile() {File file -> doSomething..}