Search for document in GroupsDocs Windows azure blob storage(using the metadata of a file)

Hi @GroupDocs team,

I have files in my Azure Storage, I have given them metadata key->value pair for each document. See the image for details
screenshot-portal.azure.com-2021.04.15-21_58_50.png (102.7 KB)
So, I need to do the processing of the files based on the metadata specified in the key value.
I don’t have the document name and extension instead I have the metadata value for the file.

Another approach could be the metadata value of the file is also happen to be the first part of the file name. For example, the file name is
WRTSC-1768280635-10438_DocsforEssaysSamplesGrade4.docx
and metadata value is WRTSC-1768280635-10438
If I can search for a file using the first part of the file name, that is WRTSC-1768280635-10438
?
Is there any possibility for achieving this. Appreciate a quick response from anyone.

Thank you,
Gopal

@gopalsharma

I think you can get a list of files/folders from the specified folder(root) using GetFilesList API method, parse the response JSON output and proceed according to your workflow.

GET ​/viewer​/storage​/folder​/{path} Get all files and folders within a folder

1 Like

Thank you so much @tilal.ahmad
I will try this and let you know, if this works or not.

@tilal.ahmad
can you please provide a sample code for listing all files in root using PHP SDK?

Thank you

@tilal.ahmad
It’s a little urgent for me to test this scenario. Can you please share the sample code with me?

 // Getting the Viewer FolderAPI API Instance
public static function GetFolderApiInstance() {
    // intializing the configuration
    $configuration = new GroupDocs\Viewer\Configuration();
    // Seting the configurations
    $configuration->setAppSid(Utils::$ClientId);
    $configuration->setAppKey(Utils::$ClientSecret);
    $configuration->setApiBaseUrl(Utils::$ApiBaseUrl);
    // Retrun the new FolderApi instance
    return new GroupDocs\Viewer\FolderApi($configuration);
}
public static function GetList() {
    $folderApi = self::GetFolderApiInstance();
    $storage = 'storagename';
		$request = new  GroupDocs\Viewer\Model\RequestsRequests\getFilesListRequest("/", $storage);
		$response = $folderApi->getFilesList($request);
		print_r($response);
    }
Following code worked for me.
        public static function GetList() {
            $folderApi = self::GetFolderApiInstance();
            $request = new GroupDocs\Viewer\Model\Requests\GetFilesListRequest("/", Utils::$MyStorage);
            $response = $folderApi->getFilesList($request);
            echo "<pre>",print_r($response,1),"</pre>";
        }

@gopalsharma

Yes, your shared code is correct. Please check the following sample code as well for reference.

// Create instance of the API
$configuration = new GroupDocs\Viewer\Configuration();
$configuration->setAppSid($myClientId);
$configuration->setAppKey($myClientSecret);
$infoApi = new GroupDocs\Viewer\InfoApi($configuration); 
$folderApi = new GroupDocs\Viewer\FolderApi($configuration); 

try {
    $request = new GroupDocs\Viewer\Model\Requests\getFilesListRequest("/");
    
    $response = $folderApi->getFilesList($request);

    foreach ($response->getValue() as $key => $name) {
        echo $name->getName() .'<br>' ."\r\n";

    }
} catch (Exception $e) {
    echo  "Something went wrong: ",  $e->getMessage(), "\n";
    PHP_EOL;
}
1 Like

Thank you so much … @tilal.ahmad. You are a saviour.

1 Like