Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 2 Support (Qt 5) › List subfolders of my website url

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #24664

    Burhan

    Hi,

    How can I list the subfolders and files in a path of my website.

    I tried to use FolderListModel but it didn^t work.

     

    Could you help me?

    #24665

    Alex
    Felgo Team

    Hi,

    what platform is this app running on? FolderListModel is intended for use with the local filesystem where the application is running on.

    Are you just providing a url and want to list the folder structure? Then you should check about a webserver feature called “directory listing”, and why this is disabled by default as it is dangerous. Or is this only about displaying a provided list of folders in an appropriate visual way?

    If you can provide more info on the use case, you maybe can get better help and an alternative approach.

    Best,
    Alex

    #24666

    Burhan

    Hi Alex,

     

    Thank you for your kind answer.

    My application (PhotoLibrary) runs on android. I have an FTP server. I can see the directories by opening the URL on a browser. So I want to be able to see the directories and download the images under the folders of the root url which I gave.

     

    Kind Regards.

    Burhan

    #24667

    Alex
    Felgo Team

    I would suggest you use an HttpRequest on that URL and then parse the response string to get the directories.

    Based on those directories you can then also request the urls of the distinct folders again to get the content of those folders.

    Best,
    Alex

    #24668

    Burhan

    Hi,

    I still search on google but couldn’t find a way to parse the directories.

    I found the below codes:

    HttpRequest
                   .get(serverUrl)
                   .timeout(5000)
                   .set('Content-Type', 'application/json; charset=UTF-8')
                   .then(function(res) {
                     console.log(res.status);
                     console.log(JSON.stringify(res.header, null, 4));
                     console.log(JSON.stringify(res.body, null, 4));

    and found “JSON.parse()” function. But couldn’t find how to parse :/

    Please, can you advise me something?

    #24669

    Burhan

    Hi,

    I’ve tried to use XmlListModel, codes are below but I couldn’t see the content of the model.

        DownloadableResource {
            id: resource
            extractAsPackage: false
            storageLocation: FileUtils.DocumentsLocation
            storageName: "qaphotolibrary.xml"
            source: serverXmlUrl
            Component.onCompleted: {
                download()
            }
        }
    
        XmlListModel {
            id: xmlModel
            source: ""
            query: "/rss/category/item"
    
            XmlRole { name: "categoryName"; query: "categoryName/string()" }
            XmlRole { name: "categoryCount"; query: "categoryCount/string()" }
    
            Component.onCompleted: {
                xmlModel.source = resource.storagePath
                console.log("XmlListModel: " + xmlModel.source + " - " + resource.storagePath )
            }
        }
    NavigationStack {
    
            Page {
                title: qsTr("Main Page")
    
                AppListView {
                    anchors.fill: parent
                    orientation: AppListView.Vertical
                    model: xmlModel
                    delegate: AppText { text: categoryName + ": " + categoryCount }
                }
            }
        }

     

    #24673

    Burhan

    Hi,

    Are there any suggestions ?

    Kind Regards.

    Thanks

    Burhan

    #24683

    Alex
    Felgo Team

    Can you post the what the output of your

    res.body

    value is of the HttpRequest that you added above? Do you see the directories there?

    By the way the “Content-Type” property of a http request just defines the type of the request (or more precisely the payload body of the request), not its response. I’d assume that the response from the server is not json formatted but rather some xml.

    Best,
    Alex

Viewing 8 posts - 1 through 8 (of 8 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded