php
2 TopicsOnedrive has stopped creating folders
I have recently implemented the Graph api to: create in a shared folder various directories with names like this => "uc_123455"; on each folder created, the api upload pdfs inside it ; the problem: it starts ok but after a time it just stop creating folder, it has a total of almost 3500 folders to create and stops after 1000. the code works like this: it first get the access_token from microsoft and load the Graph then get the shared folder ID $this->graph = new Graph(); $this->graph->setAccessToken($this->accessToken); $this->directory_id = $this->fetchDirectoryId($this->graph); then i start looping: first it create the name based on what part is of the loop $subfolderName = "UC_" . $customer->numero_uc; after this is used to create the folder on this function $folder = $this->createIntoDirectory($this->directory_id[0], $this->graph, $subfolderName); and this function works like this public function createIntoDirectory(string $folderId, Graph $graph, string $ucNumber): string|bool { try { $response = $graph->createRequest('POST', "/me/drives/" . $this->drive_id . "/items/$folderId/children") ->attachBody(json_encode([ "name" => $ucNumber, "folder" => new stdClass() ], JSON_THROW_ON_ERROR)) ->setReturnType(DriveItem::class) ->execute(); return $response->getId(); } catch (GuzzleException|GraphException) { return $this->fetchExistenteDirectory($folderId, $graph, $ucNumber); } } if already exist an Folder with the name it falls in the exception and call to another function that return the id of the already created folder (I did this in case any pdfs weren't sent to the folder) heres the function: public function fetchExistenteDirectory(string $folderId, Graph $graph, string $ucNumber): string|bool { try { $folder = $graph->createRequest('GET', "/me/drives/" . $this->drive_id . "/items/$folderId/children") ->setReturnType(DriveItem::class) ->execute(); foreach ($folder as $item) { if ($item->getName() === $ucNumber) { return $item->getId(); } } return false; } catch (GuzzleException|GraphException) { return false; } } are there problems with my code to stop generation folders? because it works 100% fine, until then it stops questions like: where is the pdf? the pdf are converted images from urls that i fetch from my db what is UC: is like users, it come from portuguese word "unidade consumidora" or "consumer unit", each of then come from an array that i fetch from my db if it has any questions about the code or the process just ask. Thanks (english isn't my mother tongue, so sorry for any grammatical error)365Views0likes0CommentsOnedrive download - Web PHP App
Hi, I have a web PHP/MySql app which uses SSO with 365 for user logins. In my app we have an area where you can download extracts (Excel, Word files) and at the moment these extracts download locally to a users device which is not secure. I would therefore like a way that when a user clicks to download the extract the system sends the file to their respective onedrive account automatically instead of downloading locally to their pc (only company compliant devices in our org can install onedrive app, the rest use the web). This is to ensure that people using BYOD or public devices cannot download these extracts locally to their devices. Also if the user does not connect to our app via their 365 SSO account, we want to ensure that when they download the extract it only opens in a read-only format in 365 online. Is this kind of thing possible?862Views0likes0Comments