패키지, 저장소 및 앱 카테고리 검색

패키지 상세v5.0.0+1

cloudinary_sdk

이것은 Cloudinary API용 Dart 패키지로, 클라우디너리 클라우드에서 파일을 업로드하고 관리할 수 있습니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
17
좋아요
35
Pub 점수
150

패키지 설치

flutter pub add cloudinary_sdk

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

cloudinary_sdk 패키지는 Cloudinary API와의 원활한 통합을 제공하는 Dart 라이브러리로, 개발자가 Flutter 애플리케이션에서 직접 멀티미디어 파일을 업로드하고 관리하며 조작할 수 있도록 합니다. Android, iOS, Web, macOS, Windows, Linux 등 다양한 플랫폼을 지원합니다. 파일 업로드 및 변환을 위한 직관적인 메서드를 통해 앱 내 클라우드 기반 미디어 처리를 간소화합니다. 소셜 미디어 플랫폼, 전자상거래 앱 또는 콘텐츠 관리 시스템과 같이 동적 이미지 및 비디오 관리가 필요한 애플리케이션에 적합합니다.

사용 사례

  • 이미지 및 비디오 업로드
  • 미디어 변환 및 최적화
  • 사용자 프로필 사진 관리
  • 모바일 앱에서의 콘텐츠 전달
  • 웹 앱에서의 동적 자산 처리
  • 실시간 미디어 처리

주요 기능

  • Cloudinary로 파일 업로드하기가 쉬워요
  • 내장된 이미지 및 비디오 변환
  • 크로스 플랫폼 지원
  • 안전한 클라우드 스토리지 통합
  • 미디어 관리를 위한 간단한 API
  • 여러 파일 형식을 지원합니다

적합한 대상

  • 미디어 중심 앱을 구축하는 플러터 개발자
  • 확장 가능한 클라우드 스토리지가 필요한 앱
  • 미디어 워크플로우에 Cloudinary를 사용하는 개발자
  • 제3자 미디어 서비스를 통합하는 팀
  • 반응형 이미지 전달이 필요한 프로젝트

고려 사항

  • Cloudinary 계정과 API 자격 증명이 필요합니다
  • Cloudinary의 서비스 기능에 제한됨
  • 업로드를 위해 네트워크 연결이 필요합니다
  • 고급 변환을 위해 추가 구성이 필요할 수 있습니다
  • 외부 Cloudinary API 안정성에 따라 다름

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

cloudinary_sdk

This is a pure dart package for Cloudinary API that allows you to do signed and unsigned uploads to your cloudinary cloud.

Description

This package is intended to be used for signed and unsigned uploads to your cloud, it allows you to destroy/delete files and makes it easy to access image url with transformations

Installation

The first thing is to add cloudinary_sdk as a dependency of your project, for this you can use the command:

For purely Dart projects

dart pub add cloudinary_sdk

For Flutter projects

flutter pub add cloudinary_sdk

This command will add cloudinary_sdk to the pubspec.yaml of your project. Finally you just have to run:

dart pub get or flutter pub get depending on the project type and this will download the dependency to your pub-cache

How to use

Initialize a Cloudinary object
/// This three params can be obtained directly from your Cloudinary account Dashboard.
/// The .full(...) factory constructor is recommended only for server side apps, where [apiKey] and 
/// [apiSecret] are secure. 
final cloudinary = Cloudinary.full(
  apiKey: apiKey,
  apiSecret: apiSecret,
  cloudName: cloudName,
);

or

/// The .basic(...) factory constructor is recommended for client side apps, where [apiKey] and 
/// [apiSecret] must not be used, so .basic(...) constructor allows to do later unsigned requests.
final cloudinary = Cloudinary.basic(
  cloudName: cloudName,
);

Optionally you can pass an apiUrl as well, but it's not required because this package uses by default https://api.cloudinary.com/v1_1 which is the current apiUrl at the time of writing this.

Do a single file signed upload

Recommended only for server side apps.

  final response = await cloudinary.uploadResource(
    CloudinaryUploadResource(
      filePath: file.path,
      fileBytes: file.readAsBytesSync(),
      resourceType: CloudinaryResourceType.image,
      folder: cloudinaryCustomFolder,
      fileName: 'some-name',
      progressCallback: (count, total) {
        print(
          'Uploading image from file with progress: $count/$total');
        })
      )
  );

  if(response.isSuccessful) {
    print('Get your image from with ${response.secureUrl}');  
  }
    

You can upload a file from path or byte array representation, you can also pass an optParams map to do a more elaborated upload according to https://cloudinary.com/documentation/image_upload_api_reference The cloudinary.uploadResource(...) function is fully documented, you can check the description to know what other options you have.

Do multiple file signed upload

Recommended only for server side apps.

  final resources = await Future.wait(files?.map((file) async =>
      CloudinaryUploadResource(
        filePath: file.path,
        fileBytes: file.readAsBytesSync(),
        resourceType: CloudinaryResourceType.image,
        folder: cloudinaryCustomFolder,
        progressCallback: (count, total) {
            print(
              'Uploading image from file with progress: $count/$total');
            })
        )
      )));
  List<CloudinaryResponse> responses = await cloudinary.uploadResources(resources);

  responses.forEach((response) {
    if(response.isSuccessful) {
      print('Get your image from with ${response.secureUrl}');    
    }
  });

This function does repeatedly calls to cloudinary.uploadResource(...) described above.

Do a single file unsigned upload

Recommended for server client side apps. The way to do this request is almost the same as above, the only difference is the uploadPreset which is required for unsigned uploads.

  final response = await cloudinary.unsignedUploadResource(
    CloudinaryUploadResource(
      uploadPreset: somePreset,
      filePath: file.path,
      fileBytes: file.readAsBytesSync(),
      resourceType: CloudinaryResourceType.image,
      folder: cloudinaryCustomFolder,
      fileName: 'some-name',
      progressCallback: (count, total) {
        print(
          'Uploading image from file with progress: $count/$total');
        })
      )
  );

  if(response.isSuccessful) {
    print('Get your image from with ${response.secureUrl}');  
  }
    

You can upload a file from path or byte array representation, you can also pass an optParams map to do a more elaborated upload according to https://cloudinary.com/documentation/image_upload_api_reference The cloudinary.uploadResource(...) function is fully documented, you can check the description to know what other options you have.

Do multiple file unsigned upload

Recommended for server client side apps. The way to do this request is almost the same as above, the only difference is the uploadPreset which is required for unsigned uploads.

  final resources = await Future.wait(files?.map((file) async =>
      CloudinaryUploadResource(
        uploadPreset: somePreset,
        filePath: file.path,
        fileBytes: file.readAsBytesSync(),
        resourceType: CloudinaryResourceType.image,
        folder: cloudinaryCustomFolder,
        progressCallback: (count, total) {
            print(
              'Uploading image from file with progress: $count/$total');
            })
        )
      )));
  List<CloudinaryResponse> responses = await cloudinary.uploadResources(resources);

  responses.forEach((response) {
    if(response.isSuccessful) {
      print('Get your image from with ${response.secureUrl}');    
    }
  });

This function does repeatedly calls to cloudinary.uploadResource(...) described above.

Do a single file delete (this will use the cloudinary destroy method)
    final response = await cloudinary.deleteResource(
      url: url,
      resourceType: CloudinaryResourceType.image,
      invalidate: false,
    );
    if(response.isSuccessful ?? false){
      //Do something else
    }

To delete a cloudinary file it´s necessary a public_id, as you can see in the sample code the deleteResource(...) function can delete a file by it's url... You can also pass an optParams map to do a more elaborated delete (destroy) according to https://cloudinary.com/documentation/image_upload_api_reference#destroy_method The cloudinary.deleteResource(...) function is fully documented, you can check the description to know what other options you have.

Do a multiple files delete (this will use the cloudinary delete resources method)
    final response = await cloudinary.deleteResources(
        urls: urlPhotos,
        resourceType: CloudinaryResourceType.image
      );
    if(response.isSuccessful ?? false){
      Map<String, dynamic> deleted = response.deleted;//in deleted Map you will find all the public ids and the status 'deleted'
    }

To delete multiple cloudinary files it´s necessary a list of public_id's, as you can see in the sample code the deleteResources(...) function can delete files from a list of urls... You can also pass an optParams map to do a more elaborated delete according to https://cloudinary.com/documentation/admin_api#delete_resources The cloudinary.deleteResources(...) function is fully documented, you can check the description to know what other options you have.

Load an Image from cloudinary with some transformations
    final cloudinaryImage = CloudinaryImage(url);
    String transformedUrl = cloudinaryImage.transform().width(256).height(256).thumb().face().opacity(30).angle(45).generate();
    return Image.network(transformedUrl);
Note:

It's recommended to check the tests and example code for a better idea of how to work with this package.

카테고리

의존성

의존성 목록 2 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.