Passer au contenu

Custom Storage

Capgo supports custom storage Solutions for your Application Bundles, allowing you to host your Mises à jour on your own infrastructure or third-party storage services. This is particularly useful for organizations with specific Sécurité requirements, compliance needs, or existing storage infrastructure.

Custom storage in Capgo works by uploading your Bundle to an external location and providing Capgo with the URL to access it. The Capgo SDK will then Télécharger Mises à jour directly from your custom storage location instead of Capgo’s default cloud storage.

The simplest way to use custom storage is by uploading your Bundle to any publicly accessible URL and providing that URL to Capgo.

Terminal window
npx @capgo/cli@latest bundle upload --external https://your-domain.com/bundles/v1.2.3.zip

This Commande tells Capgo to Référence the Bundle at the specified URL instead of uploading it to Capgo’s cloud storage.

For secure external storage, you can encrypt your Bundle and provide the decryption keys:

Terminal window
npx @capgo/cli@latest bundle upload --external https://your-domain.com/bundles/v1.2.3.zip --iv-session-key YOUR_IV_SESSION_KEY

Capgo provides built-in Support for Amazon S3 and S3-compatible storage services. The CLI can automatically Télécharger your Bundle to S3 and configure Capgo to use the S3 URL.

Terminal window
npx @capgo/cli@latest bundle upload \
--s3-region us-east-1 \
--s3-apikey YOUR_ACCESS_KEY \
--s3-apisecret YOUR_SECRET_KEY \
--s3-bucket-name your-bucket-name

For S3-compatible services or custom endpoints:

Terminal window
npx @capgo/cli@latest bundle upload \
--s3-region us-east-1 \
--s3-apikey YOUR_ACCESS_KEY \
--s3-apisecret YOUR_SECRET_KEY \
--s3-endpoint https://s3.your-provider.com \
--s3-bucket-name your-bucket-name \
--s3-port 443 \
--no-s3-ssl # Only if your endpoint doesn't support SSL
ParamètreDescriptionRequired
--s3-regionAWS region for your S3 bucketYes
--s3-apikeyS3 access key IDYes
--s3-apisecretS3 secret access keyYes
--s3-bucket-nameName of your S3 bucketYes
--s3-endpointCustom S3 endpoint URLNo
--s3-portPort for S3 endpointNo
--no-s3-sslDisable SSL for S3 uploadNo

When using custom storage, especially with Chiffrement, you need to prepare your Bundles properly. This involves creating a zip file and optionally encrypting it.

First, Créer a zip file of your Application Bundle:

Terminal window
npx @capgo/cli@latest bundle zip com.example.app --path ./dist

The zip command will return the checksum of the zip file. You can use this checksum to encrypt the zip file if needed. Use the --json option to get structured output including the checksum.

Terminal window
npx @capgo/cli@latest bundle zip [appId] \
--path ./dist \
--bundle 1.2.3 \
--name myapp-v1.2.3 \
--json \
--no-code-check \
--key-v2 \
--package-json ../../package.json,./package.json
OptionDescription
--pathPath to the folder to zip (defaults to webDir from capacitor.config)
--bundleBundle version number to name the zip file
--nameCustom name for the zip file
--jsonOutput results in JSON format (includes checksum)
--no-code-checkSkip checking for notifyAppReady() call and index file
--key-v2Use encryption v2
--package-jsonPaths to package.json files for monorepos (comma separated)

For enhanced Sécurité, encrypt your zip Bundle before uploading:

Terminal window
# Using default local key
npx @capgo/cli@latest bundle encrypt ./myapp.zip CHECKSUM
# Using custom key file
npx @capgo/cli@latest bundle encrypt ./myapp.zip CHECKSUM --key ./path/to/.capgo_key_v2
# Using key data directly
npx @capgo/cli@latest bundle encrypt ./myapp.zip CHECKSUM --key-data "PRIVATE_KEY_CONTENT"

The CHECKSUM parameter is required and should be the checksum of your zip file. You can get the checksum from the zip command output (use --json option for structured output).

By default, the encrypt command will use your local private signing key. You can specify a custom key using the --key or --key-data options.

The encrypt command will return the ivSessionKey needed for upload or decryption.

OptionDescription
zipPathPath to the zip file to encrypt (required)
checksumChecksum of the zip file (required) - get it from zip command
--keyCustom path for private signing key (optional, uses local key by default)
--key-dataPrivate signing key data directly (optional)
--jsonOutput results in JSON format
  1. Construction your Application:

    Terminal window
    npm run build
  2. Créer a zip Bundle:

    Terminal window
    npx @capgo/cli@latest bundle zip com.example.app --path ./dist --bundle 1.2.3

    Remarque the checksum returned by this Commande.

  3. Encrypt the Bundle:

    Terminal window
    npx @capgo/cli@latest bundle encrypt ./com.example.app-1.2.3.zip CHECKSUM_FROM_STEP_2

    Note the ivSessionKey from the output.

  4. Télécharger to your storage: Télécharger the Chiffré zip file to your hosting service.

  5. Register with Capgo:

    Terminal window
    npx @capgo/cli@latest bundle upload \
    --external https://your-cdn.com/bundles/com.example.app-1.2.3.zip \
    --iv-session-key IV_SESSION_KEY_FROM_STEP_3
  1. Construction your Application:

    Terminal window
    npm run build
  2. Télécharger directly to S3:

    Terminal window
    npx @capgo/cli@latest bundle upload \
    --s3-region us-west-2 \
    --s3-apikey YOUR_ACCESS_KEY \
    --s3-apisecret YOUR_SECRET_KEY \
    --s3-bucket-name your-app-bundles \
    --channel Production
  1. Construction and zip:

    Terminal window
    npm run build
    npx @capgo/cli@latest bundle zip com.example.app --path ./dist --key-v2
  2. Encrypt the Bundle:

    Terminal window
    npx @capgo/cli@latest bundle encrypt ./com.example.app.zip CHECKSUM
  3. Télécharger to S3 with Chiffrement:

    Terminal window
    npx @capgo/cli@latest bundle upload \
    --s3-region us-west-2 \
    --s3-apikey YOUR_ACCESS_KEY \
    --s3-apisecret YOUR_SECRET_KEY \
    --s3-bucket-name your-app-bundles \
    --iv-session-key IV_SESSION_KEY_FROM_STEP_2 \
    --channel Production

When using custom storage, consider these Sécurité best practices:

  • Ensure your storage URLs are accessible to your Application Utilisateurs but not publicly discoverable
  • Use signed URLs or token-based authentication when possible
  • Implement proper CORS headers for web-based apps
  • Always encrypt sensitive Bundles using the Capgo Chiffrement tools
  • Store Chiffrement keys securely and rotate them regularly
  • Use HTTPS for all Bundle URLs (required for iOS and Android)
  • Monitor access Journaux to detect unusual Télécharger patterns
  • Set up alerts for Échoué Bundle downloads
  • Regularly audit your storage permissions

Bundle not downloading:

  • Verify the URL is publicly accessible and uses HTTPS (required for iOS and Android)
  • Vérifier CORS headers for web apps
  • Ensure the Bundle format is correct

Encryption errors:

  • Verify the ivSessionKey matches the encrypted bundle
  • Vérifier that the Bundle was Chiffré with the correct key
  • Ensure Chiffrement v2 is used for Nouveau Bundles

S3 upload failures:

  • Verify your S3 credentials and permissions
  • Vérifier bucket policies and CORS Configuration
  • Ensure the specified region is correct

Vérifier Bundle status:

Terminal window
npx @capgo/cli@latest app debug

Verify Bundle integrity:

Terminal window
npx @capgo/cli@latest bundle list
  • Learn À propos [Canaux](/docs/live-Mises à jour/Canaux/) to manage different Déploiement environments
  • Explore [Mise à jour Behavior](/docs/live-Mises à jour/Mise à jour-behavior/) to customize how Mises à jour are applied
  • Set up CI/CD Integration to automate your custom storage workflow