Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Objective-C) Bunny Edge Storage - List FilesSee more Bunny CDN ExamplesRetrieve a list of files and directories located in the given directory. For more information, see https://docs.bunny.net/reference/get_-storagezonename-path-
#import <CkoHttp.h> #import <CkoStringBuilder.h> #import <CkoJsonArray.h> #import <CkoJsonObject.h> #import <NSString.h> // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkoHttp *http = [[CkoHttp alloc] init]; BOOL success; // Use the "Password" from the "FTP & HTTP API Access" console web page for your Bunny storage zone. [http SetRequestHeader: @"AccessKey" value: @"YOUR_FTP_AND_HTTP_PASSWORD"]; // Storage Endpoints: // The storage API endpoint depends on the primary storage region of your storage zone. You can also find this in the FTP & HTTP API Information of your storage zone. // Falkenstein: storage.bunnycdn.com // New York: ny.storage.bunnycdn.com // Los Angeles: la.storage.bunnycdn.com // Singapore: sg.storage.bunnycdn.com // Sydney: syd.storage.bunnycdn.com // London: uk.storage.bunnycdn.com // ... (possibly others??) CkoStringBuilder *sbResponse = [[CkoStringBuilder alloc] init]; // Change the "storageZoneName" to your actual storage zone name. success = [http QuickGetSb: @"https://uk.storage.bunnycdn.com/storageZoneName/testDir/" sbContent: sbResponse]; if (success == NO) { NSLog(@"%@",http.LastErrorText); return; } int statusCode = [http.LastStatus intValue]; NSLog(@"%@%d",@"Status code = ",statusCode); if (statusCode != 200) { NSLog(@"%@",[sbResponse GetAsString]); NSLog(@"%@",@"Failed."); return; } CkoJsonArray *jarr = [[CkoJsonArray alloc] init]; [jarr LoadSb: sbResponse]; jarr.EmitCompact = NO; NSLog(@"%@",[jarr Emit]); // Here is a sample response. Parsing code is shown below.. // [ // { // "Guid": "ebd9ccff-faf7-449d-9c71-8662b9f3cf41", // "StorageZoneName": "chilkat", // "Path": "/chilkat/testDir/", // "ObjectName": "seahorse.jpg", // "Length": 24388, // "LastChanged": "2023-04-21T15:59:08.382", // "ServerId": 586, // "ArrayNumber": 0, // "IsDirectory": false, // "UserId": "6d26ab35-2914-422c-9378-d51f38166e53", // "ContentType": "", // "DateCreated": "2023-04-21T15:59:08.382", // "StorageZoneId": 266805, // "Checksum": "0503558E7B4D141C067BEECFD06F87F6F58B81E37918310F82C7C4077D27BD1D", // "ReplicatedZones": "SE,DE,LA,SG,JH,BR,SYD,NY" // }, // { // "Guid": "e74b85f8-4d5d-459e-a2fc-0fcfa8c926aa", // "StorageZoneName": "chilkat", // "Path": "/chilkat/testDir/", // "ObjectName": "seal.jpg", // "Length": 342708, // "LastChanged": "2023-04-21T15:59:08.763", // "ServerId": 586, // "ArrayNumber": 2, // "IsDirectory": false, // "UserId": "6d26ab35-2914-422c-9378-d51f38166e53", // "ContentType": "", // "DateCreated": "2023-04-21T15:59:08.763", // "StorageZoneId": 266805, // "Checksum": "C95F946A0299CE39C20A072B3DC581446B2EE2D94CA93901B58604F4EFB8AAB5", // "ReplicatedZones": "DE,SE,SG,LA,JH,BR,SYD,NY" // }, // { // "Guid": "ca80cdbd-c6cf-445d-b367-0b33de7ae65a", // "StorageZoneName": "chilkat", // "Path": "/chilkat/testDir/", // "ObjectName": "university.jpg", // "Length": 277581, // "LastChanged": "2023-04-21T15:59:10.142", // "ServerId": 586, // "ArrayNumber": 0, // "IsDirectory": false, // "UserId": "6d26ab35-2914-422c-9378-d51f38166e53", // "ContentType": "", // "DateCreated": "2023-04-21T15:59:10.142", // "StorageZoneId": 266805, // "Checksum": "96A10EAA1B778C066739A6233206022DB219B67A8775401D7865F40E6DD83571", // "ReplicatedZones": "DE,SE,SG,JH,BR,LA,SYD,NY" // } // ] // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON CkoJsonObject *json = 0; NSString *Guid = 0; NSString *StorageZoneName = 0; NSString *Path = 0; NSString *ObjectName = 0; int Length; NSString *LastChanged = 0; int ServerId; int ArrayNumber; BOOL IsDirectory; NSString *UserId = 0; NSString *ContentType = 0; NSString *DateCreated = 0; int StorageZoneId; NSString *Checksum = 0; NSString *ReplicatedZones = 0; int i = 0; int count_i = [jarr.Size intValue]; while (i < count_i) { json = [jarr ObjectAt: [NSNumber numberWithInt: i]]; Guid = [json StringOf: @"Guid"]; StorageZoneName = [json StringOf: @"StorageZoneName"]; Path = [json StringOf: @"Path"]; ObjectName = [json StringOf: @"ObjectName"]; Length = [[json IntOf: @"Length"] intValue]; LastChanged = [json StringOf: @"LastChanged"]; ServerId = [[json IntOf: @"ServerId"] intValue]; ArrayNumber = [[json IntOf: @"ArrayNumber"] intValue]; IsDirectory = [json BoolOf: @"IsDirectory"]; UserId = [json StringOf: @"UserId"]; ContentType = [json StringOf: @"ContentType"]; DateCreated = [json StringOf: @"DateCreated"]; StorageZoneId = [[json IntOf: @"StorageZoneId"] intValue]; Checksum = [json StringOf: @"Checksum"]; ReplicatedZones = [json StringOf: @"ReplicatedZones"]; i = i + 1; } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.