I am new at IOS - Swift language. I am just trying to pass this android code below that includes org.apache.ivy.util.url.ApacheURLLister module. Is there any way for Swift to get a list of files and folders in an Url? (example; 1.jpg , dot.jpg in 'www.example.com/images/')
我是IOS的新手 - Swift语言。我只是想在下面传递这个包含org.apache.ivy.util.url.ApacheURLLister模块的android代码。有没有办法让Swift获取Url中的文件和文件夹列表? (示例; 1.jpg,'www.example.com/images/'中的dot.jpg)
public static ArrayList<URL> getFileList(URL url1) {
ArrayList<URL> serverDir = new ArrayList<>();
try {
ApacheURLLister lister1 = new ApacheURLLister();
serverDir.addAll(lister1.listAll(url1));
System.out.println(serverDir);
} catch (Exception e) {
Log.e("getFileList", "Error listing url " + url);
e.printStackTrace();
}
return serverDir;
}
1 个解决方案
#1
0
I figured it out by using Alamofire;
我通过使用Alamofire弄清楚了;
func getFileList(url: String,files_downloaded: Bool, got_xmls_on_sd_card: Bool, _directory: NSString,building_folder: NSURL) {
Alamofire.request(.GET, url)
.responseJSON { response in
guard response.result.error == nil else {
print("Error on request getFileList()")
print(response.result.error)
return
}
if let value: AnyObject = response.result.value {
let results = JSON(value)
var fileList : [String] = []
for i in 0..<results.count {
//TODO fill fileList with urls
}
//TODO return fileList
}
}
}
#1
0
I figured it out by using Alamofire;
我通过使用Alamofire弄清楚了;
func getFileList(url: String,files_downloaded: Bool, got_xmls_on_sd_card: Bool, _directory: NSString,building_folder: NSURL) {
Alamofire.request(.GET, url)
.responseJSON { response in
guard response.result.error == nil else {
print("Error on request getFileList()")
print(response.result.error)
return
}
if let value: AnyObject = response.result.value {
let results = JSON(value)
var fileList : [String] = []
for i in 0..<results.count {
//TODO fill fileList with urls
}
//TODO return fileList
}
}
}