简体   繁体   中英

Find out if a folder or file already exists

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?

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM