DEV Community

Cover image for # Unified Cloud Storage API: Integrating Google Drive and OneDrive With a Single Interface
MergeDrive
MergeDrive

Posted on

# Unified Cloud Storage API: Integrating Google Drive and OneDrive With a Single Interface

Integrating one cloud storage provider into a SaaS application is relatively straightforward. Integrating multiple providers while maintaining a consistent developer experience is a different challenge.

Each provider has its own authentication mechanisms, file management endpoints, upload workflows, error responses, and limitations.

I'm the founder and developer of MergeDrive, a multi-cloud storage management project involving Google Drive and OneDrive. This article explores the architectural challenges relevant to building such a platform.

Table of Contents

  1. What is a unified cloud storage API?
  2. Challenges of multi-cloud integration
  3. Designing a unified API
  4. Smart storage selection
  5. Resumable file uploads
  6. Webhooks and asynchronous operations
  7. Security considerations
  8. MergeDrive as a project context
  9. Conclusion

1. What Is a Unified Cloud Storage API?

A unified cloud storage API provides a common interface for interacting with multiple cloud storage providers.

Instead of implementing provider-specific logic throughout your application, you introduce an abstraction layer that handles the differences between providers.

A unified interface can expose common operations such as:

  • File uploads and downloads.
  • File and folder management.
  • Storage availability monitoring.
  • File metadata retrieval.
  • Cloud account management.

The underlying adapters communicate with the respective cloud storage APIs.

2. Challenges of Multi-Cloud Storage Integration

Google Drive and OneDrive provide similar storage capabilities but implement them differently.

Capability Google Drive OneDrive
API Google Drive API Microsoft Graph
Authentication Google OAuth 2.0 Microsoft identity platform
File identifiers File IDs DriveItem IDs
Large file uploads Resumable uploads Upload sessions

Supporting both providers requires handling differences in:

  • OAuth permissions and token refresh.
  • API response structures.
  • Pagination.
  • Rate limits.
  • File size restrictions.
  • Error handling.
  • Upload session management.

A unified cloud storage API can centralize much of this complexity.

3. Designing a Unified Cloud Storage API

The adapter design pattern provides a useful architectural foundation.

A common TypeScript interface could look like this:

type CloudProvider = "google-drive" | "onedrive";

interface CloudFile {
  id: string;
  name: string;
  provider: CloudProvider;
  size?: number;
}

interface StorageAdapter {
  upload(
    accountId: string,
    name: string,
    content: Uint8Array
  ): Promise<CloudFile>;

  listFiles(
    accountId: string
  ): Promise<CloudFile[]>;

  deleteFile(
    accountId: string,
    fileId: string
  ): Promise<void>;
}
Enter fullscreen mode Exit fullscreen mode

This is a conceptual interface, not the actual MergeDrive SDK or API contract.

Each provider implements its own adapter while the application communicates through the common interface.

The architecture looks like this:

SaaS Application
       |
Unified Storage API
       |
       +-- Google Drive Adapter
       |          |
       |     Google Drive API
       |
       +-- OneDrive Adapter
                  |
             Microsoft Graph
Enter fullscreen mode Exit fullscreen mode

This approach separates application logic from provider-specific implementation details.

4. Smart Storage Selection

A multi-cloud API can do more than normalize endpoints.

It can also help determine which connected account should receive a file.

Consider the following scenario:

Account Available storage
Google Drive A 0 GB
Google Drive B 10 GB
OneDrive A 4 GB

For a 6 GB upload, Google Drive B has sufficient capacity.

A simple storage selection algorithm could look like this:

interface StorageAccount {
  id: string;
  availableBytes: number;
  priority: number;
}

function selectAccount(
  accounts: StorageAccount[],
  fileSize: number
) {
  return accounts
    .filter(account =>
      account.availableBytes >= fileSize
    )
    .sort((a, b) => b.priority - a.priority)[0]
    ?? null;
}
Enter fullscreen mode Exit fullscreen mode

A production implementation would also need to consider permissions, provider limitations, concurrent uploads, and changing storage availability.

Importantly, managing multiple cloud accounts does not physically combine their individual storage quotas.

5. Why Resumable Upload APIs Matter

Large file uploads can fail because of network interruptions, temporary API failures, or expired sessions.

Restarting an entire upload consumes unnecessary bandwidth and time.

Google Drive supports resumable uploads, while Microsoft Graph provides upload sessions.

A unified upload service can track:

  • Upload session identifiers.
  • Confirmed byte offsets.
  • Upload progress.
  • Retry attempts.
  • Session expiration.
  • Completion status.

Priority queues and scheduled uploads are additional architectural options for applications handling multiple concurrent upload requests.

For large files, production systems should also consider streaming or chunked processing instead of loading the entire file into memory.

6. Cloud Storage Webhooks and Asynchronous Operations

Large uploads and background storage operations may not complete within a single HTTP request.

An asynchronous architecture can use background jobs and application-level webhooks to communicate operation status.

An illustrative webhook payload might look like this:

{
  "event": "upload.completed",
  "eventId": "evt_example",
  "data": {
    "fileId": "file_example",
    "provider": "google-drive",
    "status": "completed"
  }
}
Enter fullscreen mode Exit fullscreen mode

This example represents a hypothetical application-level event, not a documented MergeDrive webhook payload.

Reliable webhook implementations should support signature verification, retry handling, duplicate event detection, and idempotent processing.

7. Security Considerations

Cloud storage integrations require careful handling of user credentials and files.

Important considerations include:

  • Secure OAuth token storage.
  • Minimum required permission scopes.
  • Account ownership verification.
  • File-level authorization.
  • Customer data isolation.
  • Webhook signature verification.
  • Access revocation.
  • Protection against unauthorized downloads.

For collaborative applications, viewer and contributor permissions can help distinguish read access from file submission capabilities.

Scheduled access revocation is another useful design consideration for temporary collaborations.

8. MergeDrive: A Multi-Cloud Storage Project

MergeDrive is the project I'm developing in this problem space.

It brings together several areas discussed in this article:

Area Relevant functionality
Multi-cloud management Google Drive and OneDrive account integration
Developer integration Unified cloud storage API and webhooks
Upload orchestration Smart storage selection, priority, scheduled and resumable uploads
Storage management Account prioritization and storage monitoring
Collaboration Viewer and contributor permissions
Access lifecycle Manual and scheduled sharing access revocation
File protection Secondary file copies

These capabilities illustrate why a multi-cloud platform involves more than simply forwarding API requests to different providers.

The code in this article describes general architectural patterns. For actual MergeDrive capabilities and integration contracts, refer to the project's documentation.

Project website: https://mergedrive.online/

9. Conclusion

A unified cloud storage API can simplify multi-provider integration by separating business logic from provider-specific implementations.

However, abstraction alone is not enough.

A reliable architecture also needs to account for storage availability, upload reliability, authentication, asynchronous operations, error handling, and access control.

Start with a small interface, implement provider adapters, and introduce additional capabilities as your application's requirements evolve.

How are you handling multiple cloud storage providers in your applications? Are you using separate integrations or a unified abstraction layer?

References


Disclosure: I am the founder of MergeDrive. This article was drafted with AI assistance. The code examples are illustrative architectural examples, not tested production code or official MergeDrive API contracts.

Top comments (0)