npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@capawesome/capacitor-cloudinary

v6.0.0

Published

Unofficial Capacitor plugin for integrating with Cloudinary.

Downloads

936

Readme

@capawesome/capacitor-cloudinary

Unofficial Capacitor plugin for Cloudinary SDK.[^1]

Features

Capacitor Cloudinary allows you to use the native Cloudinary SDKs to upload files directly from the filesystem without going through the WebView.

Installation

npm install @capawesome/capacitor-cloudinary
npx cap sync

Android

This API requires the following permission be added to your AndroidManifest.xml before the application tag:

<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />

You also need to add the following receiver inside the application tag in your AndroidManifest.xml:

<receiver android:name="io.capawesome.capacitorjs.plugins.cloudinary.DownloadBroadcastReceiver" android:exported="true">
  <intent-filter>
    <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
  </intent-filter>
</receiver>

Variables

This plugin will use the following project variables (defined in your app’s variables.gradle file):

  • $cloudinaryAndroidVersion version of com.cloudinary:cloudinary-android (default: 2.3.0)

Configuration

No configuration required for this plugin.

Demo

A working example can be found here: robingenz/capacitor-plugin-demo

Usage

import { Cloudinary, ResourceType } from '@capawesome/capacitor-cloudinary';

const initialize = async () => {
  await Cloudinary.initialize({ cloudName: 'my_cloud_name' });
};

const uploadResource = async () => {
  await Cloudinary.uploadResource({
    path: 'file:///var/mobile/Containers/Data/Application/22A433FD-D82D-4989-8BE6-9FC49DEA20BB/Images/test.png',
    publicId: 'my_public_id',
    resourceType: ResourceType.image,
    uploadPreset: 'my_preset',
  });
};

const downloadResource = async () => {
  const { path } = await Cloudinary.downloadResource({
    url: 'https://res.cloudinary.com/myCloudName/image/upload/v123/123.png',
  });
  return path;
};

API

initialize(...)

initialize(options: InitializeOptions) => Promise<void>

Initialize the plugin.

This method must be called once before all other methods.

| Param | Type | | ------------- | --------------------------------------------------------------- | | options | InitializeOptions |

Since: 0.0.1


uploadResource(...)

uploadResource(options: UploadResourceOptions) => Promise<UploadResourceResult>

Upload a file to Cloudinary.

Note: Currently, only unsigned uploads are supported.

| Param | Type | | ------------- | ----------------------------------------------------------------------- | | options | UploadResourceOptions |

Returns: Promise<UploadResourceResult>

Since: 0.0.1


downloadResource(...)

downloadResource(options: DownloadResourceOptions) => Promise<DownloadResourceResult>

Download a file from Cloudinary.

On Android, the file will be downloaded to the Downloads directory. On iOS, the file will be downloaded to the temporary directory.

It is recommended to copy the file to a permanent location for further processing after downloading.

| Param | Type | | ------------- | --------------------------------------------------------------------------- | | options | DownloadResourceOptions |

Returns: Promise<DownloadResourceResult>

Since: 0.0.3


Interfaces

InitializeOptions

| Prop | Type | Description | Since | | --------------- | ------------------- | ----------------------------------------------------------------------------------- | ----- | | cloudName | string | The cloud name of your app which you can find in the Cloudinary Management Console. | 0.0.1 |

UploadResourceResult

| Prop | Type | Description | Since | | ---------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------- | ----- | | assetId | string | The unique asset identifier of the uploaded resource. Only available on Android and Web. | 0.0.1 | | bytes | number | The number of bytes of the uploaded resource. | 0.0.1 | | createdAt | string | The timestamp at which the resource was uploaded. | 0.0.1 | | duration | number | The duration of the uploaded resource in seconds. | 0.1.5 | | format | string | The format of the uploaded resource. | 0.0.1 | | height | number | The height of the uploaded resource. | 0.1.4 | | originalFilename | string | The original filename of the uploaded resource. Only available on Android and iOS. | 0.0.1 | | resourceType | ResourceType | The resource type of the uploaded resource. | 0.0.1 | | publicId | string | The unique public identifier of the uploaded resource. | 0.0.1 | | url | string | The url of the uploaded resource. | 0.0.1 | | secureUrl | string | The secure url of the uploaded resource. | 5.1.0 | | width | number | The width of the uploaded resource. | 0.1.4 |

UploadResourceOptions

| Prop | Type | Description | Since | | ------------------ | ----------------------------------------------------- | ------------------------------------------------------------------ | ----- | | resourceType | ResourceType | The resource type to upload. | 0.0.1 | | blob | Blob | The file to upload. Only available on Web. | 0.0.1 | | uploadPreset | string | The selected upload preset. | 0.0.1 | | path | string | The path of the file to upload. Only available on Android and iOS. | 0.0.1 | | publicId | string | Assign a unique public identifier to the resource. | 0.0.1 |

DownloadResourceResult

| Prop | Type | Description | Since | | ---------- | ------------------- | -------------------------------------------------------------------------------------------------------- | ----- | | path | string | The path of the downloaded resource where it is stored on the device. Only available on Android and iOS. | 0.0.3 | | blob | Blob | The downloaded resource as a blob. Only available on Web. | 0.0.1 |

DownloadResourceOptions

| Prop | Type | Description | Since | | --------- | ------------------- | ------------------------------------ | ----- | | url | string | The url of the resource to download. | 0.0.3 |

Enums

ResourceType

| Members | Value | Since | | ----------- | -------------------- | ----- | | Image | 'image' | 0.0.1 | | Video | 'video' | 0.0.1 | | Raw | 'raw' | 0.0.1 |

Utils

See docs/utils/README.md.

Changelog

See CHANGELOG.md.

License

See LICENSE.

Credits

This plugin is based on the Capacitor Cloudinary plugin. Thanks to everyone who contributed to the project!

[^1]: This project is not affiliated with, endorsed by, sponsored by, or approved by Cloudinary Ltd. or any of their affiliates or subsidiaries.