| name | cloud-storage-paths |
| description | Cross-platform cloud storage path resolution — OneDrive, iCloud, Dropbox path discovery and normalization |
| lastReviewed | 2026-04-30T00:00:00.000Z |
Cloud Storage Paths
Category: Cross-Platform
Time Saved: 1-2 hours debugging path resolution
Battle-tested: Yes — iCloud, OneDrive, Dropbox variants
The Problem
Your app needs to find the user's iCloud Drive (or OneDrive, Dropbox, Google Drive). You hardcode ~/iCloudDrive and it works on your machine. Users report "folder not found" errors.
Why It Happens
Cloud storage paths vary by:
- Provider — Each has different naming conventions
- OS — Same provider has different paths per OS
- Account type — Personal vs Business often differ
- Installation method — App Store vs direct download
- Version — Paths change between app versions
The Rule
Use a candidate-list approach. Check all known paths in priority order. Return first that exists.
Path Variants by Provider
iCloud Drive
| Platform | Possible Paths |
|---|
| macOS | ~/Library/Mobile Documents/com~apple~CloudDocs/ |
| Windows | %USERPROFILE%\iCloudDrive\ |
| Windows | %USERPROFILE%\iCloud Drive\ (space) |
| Windows | %USERPROFILE%\iCloud~com~apple~CloudDocs\ |
OneDrive
| Account Type | Windows Path |
|---|
| Personal | %USERPROFILE%\OneDrive\ |
| Business | %USERPROFILE%\OneDrive - CompanyName\ |
| Education | %USERPROFILE%\OneDrive - SchoolName\ |
macOS: ~/Library/CloudStorage/OneDrive-Personal/ or ~/Library/CloudStorage/OneDrive-CompanyName/
Dropbox
| Platform | Possible Paths |
|---|
| Windows | %USERPROFILE%\Dropbox\ |
| Windows | %APPDATA%\Dropbox\ (older) |
| macOS | ~/Dropbox/ |
| macOS | ~/Library/CloudStorage/Dropbox/ (newer) |
Google Drive
| Platform | Possible Paths |
|---|
| Windows | %USERPROFILE%\Google Drive\ |
| Windows | G:\My Drive\ (mapped drive) |
| macOS | ~/Google Drive/ |
| macOS | ~/Library/CloudStorage/GoogleDrive-email/ |
Implementation Pattern
const fs = require('fs');
const path = require('path');
const os = require('os');
function findCloudStorage(provider) {
const home = os.homedir();
const candidates = getCandidates(provider, home);
for (const candidate of candidates) {
if (fs.existsSync(candidate)) {
return candidate;
}
}
return null;
}
function getCandidates(provider, home) {
const isWindows = process.platform === 'win32';
switch (provider) {
case 'icloud':
return isWindows ? [
path.join(home, 'iCloudDrive'),
path.join(home, 'iCloud Drive'),
path.join(home, 'iCloud~com~apple~CloudDocs'),
] : [
path.join(home, 'Library/Mobile Documents/com~apple~CloudDocs'),
];
case 'onedrive':
return isWindows ? [
path.join(home, ),
...(home),
] : [
path.(home, ),
...(home),
];
:
isWindows ? [
path.(home, ),
path.(process.. || , ),
] : [
path.(home, ),
path.(home, ),
];
:
[];
}
}
() {
paths = [];
{
entries = fs.(home);
( entry entries) {
(entry.()) {
paths.(path.(home, entry));
}
}
} { }
paths;
}
Environment Variable Hints
Some providers set environment variables:
process.env.OneDrive
process.env.OneDriveCommercial
const onedrive = process.env.OneDrive || findCloudStorage('onedrive');
Verification Checklist
Common Symptoms
- "Works on my machine" with cloud storage
- "Folder not found" on user machines
- Different paths in bug reports
Related Skills
vscode-cross-platform-paths — VS Code config paths
line-ending-parsing — Cross-platform file handling