1

I am using the library: Kunnu

Trying to create a folder via:

$dbx->createFolder('/NameFolder');

It works.
Only when you re-update, it gives an error:

Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: POST https://api.dropboxapi.com/2/files/create_folder resulted in a 409 Conflict response: {"error_summary": "path/conflict/folder/..", "error": {".tag": "path", "path": {".tag": "conflict", "conflict": {".tag": (truncated...)

Tried to track down the error via:

try {
    $dbx->createFolder('/NameFolder');
} catch(Exception $e) { 
    
}

Did not work out.
What should I do and how do I know if a folder already exists or a file?

FixiDens
  • 29
  • 7
  • It's better to check if the folder already exists *beforehand* and avoid the exception. – Itay Sep 09 '20 at 09:28
  • @Itay, This is the question, how to check it? – FixiDens Sep 09 '20 at 09:29
  • Does this answer your question? [How do I check if a directory exists? "is\_dir", "file\_exists" or both?](https://stackoverflow.com/questions/5425891/how-do-i-check-if-a-directory-exists-is-dir-file-exists-or-both) – Itay Sep 09 '20 at 09:31
  • @Itay, It does not work, it checks the link, in addition, authorization will also be needed there, it also looks at the availability of the link, and I need to check the folder for existence. – FixiDens Sep 09 '20 at 10:49

1 Answers1

0

In general, i do not know what kind of business, but in general, it turned out all the same, through try-catch, like this:

try {
    return $dbx->createFolder($path);
} catch(\Exception $e) {
    return false;
}
FixiDens
  • 29
  • 7