GithubHelp home page GithubHelp logo

cloudinary / cloudinary_kotlin Goto Github PK

View Code? Open in Web Editor NEW
10.0 18.0 5.0 5.87 MB

Cloudinary Kotlin SDK library

License: MIT License

Kotlin 96.14% Shell 0.36% JavaScript 0.96% TypeScript 2.54%
cloudinary-sdk

cloudinary_kotlin's Introduction

Cloudinary Kotlin SDK

Build Status

About

The Cloudinary Kotlin SDK allows you to quickly and easily integrate your application with Cloudinary. Effortlessly optimize and transform your cloud's assets.

Additional documentation

This Readme provides basic installation and usage information. For the complete documentation, see the Kotlin SDK Guide.

Table of Contents

Key Features

Version Support

SDK Version Kotlin Version
1.x > 1.0

Installation

Add the SDK to your project as a dependency, we recommend using a build management tool such as Maven or Gradle to do this.

Using Gradle:

Add the Cloudinary Kotlin SDK to the dependencies section of your build.gradle file.

implementation 'com.cloudinary:kotlin-url-gen:1.8.0'

Using Maven:

Add the Cloudinary Kotlin SDK to the list of dependencies in your pom.xml file.

<dependency>
  <groupId>com.cloudinary</groupId>
  <artifactId>kotlin-url-gen</artifactId>
  <version>1.8.0</version>
  <type>pom</type>
</dependency>

Usage

Setup

The Cloudinary class is the main entry point for using the library. Your cloud_name is required to create an instance of this class. Your api_key and api_secret are also needed to perform secure API calls to Cloudinary (e.g., image and video uploads). Setting the configuration parameters can be done either programmatically using an appropriate constructor of the Cloudinary class or globally using an environment variable. You can find your account-specific configuration parameters in the Dashboard page of your account console.

Here's an example of setting configuration parameters in your Kotlin application:

import com.cloudinary.*

...
private val cloudinary = Cloudinary("cloudinary://<your-api-key>:<your-api-secret>@<your-cloud-name>")

Transform and Optimize Assets

Generate a Cloudinary URL using the cloudinary.media helper method and pass this to your image or video view:

For example, to generate a url for an image called sample on the demo account, and resize it using the fill method:

A transformation is also added to the image - cropping and using the sepia effect:

 val cloudinary = Cloudinary("cloudinary://@demo")
 val url = cloudinary.image {
   publicId("sample")
   resize(Resize.fill {
     width(100)
     height(150)
   })
 }
 println(url.generate())

This will output the following url: https://res.cloudinary.com/demo/image/upload/c_fill,h_150,w_100/sample.jpg

Uploading Assets

To upload a file you need to call you cloudinary object with uploader(), here's an example:

cloudinary.uploader().upload(imageFile) { 
    params {
      uploadPreset = "sample_preset"
    }
    options {
      unsigned = true
    }
}

Contributions

See contributing guidelines.

Get Help

If you run into an issue or have a question, you can either:

About Cloudinary

Cloudinary is a powerful media API for websites and mobile apps alike, Cloudinary enables developers to efficiently manage, transform, optimize, and deliver images and videos through multiple CDNs. Ultimately, viewers enjoy responsive and personalized visual-media experiences—irrespective of the viewing device.

Additional Resources

Licence

Released under the MIT license.

cloudinary_kotlin's People

Contributors

adimiz1 avatar michalkcloudinay avatar nitzanj avatar njb90 avatar patrick-tolosa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudinary_kotlin's Issues

SDK not dropping exisitng image/upload in the URL

When the URL to be processed contains image/upload, that should be dropped from path to remove duplicacy.

For example:
This URL
https://something.furlenco.com/image/upload/v1/bucket/products/5900/hero/1702711218.jpg

should be processed to
https://res.cloudinary.com/key/image/upload/dpr_1.0,named_trans,w_500/v1/bucket/products/5900/hero/1702711218.jpg? (iOS SDK does this transformation, removing image/upload from the end path)

But Kotlin SDK sends out this
https://res.cloudinary.com/key/image/upload/named_trans/c_scale,w_500/dpr_1.0/image/upload/v1/bucket/products/5900/hero/1702711218.jpg? (notice a couple of image/upload)

Checking the iOS SDK, it does have logic to find and drop things like image/upload..

Screenshot 2024-03-29 at 4 51 37 PM

Can you help me understand why is Kotlin SDK not equipped with a similar logic? Due to this we are not able use the same URL format for both Android and iOS clients.

Support raw transformations

I greatly appreciate the type-safety this SDK provides when working with Cloudinary. However, for certain images, my use case requires the ability to add a set of predefined raw transformations at runtime, as provided by our backend.

The iOS SDK contains a rawTransformation function, as documented here: https://cloudinary.com/documentation/ios_image_manipulation#add_transformations

Requesting the addition of a similar function for the Kotlin SDK. As a workaround I am needing to manipulate the final generated URL which is not ideal.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.