Giter Club home page Giter Club logo

firebase-extensions's Introduction

Firebase Extensions

Chat on Discord

A collection of Firebase Extensions built by Invertase.

New to Extensions? You can learn more at the Firebase Extensions product page.

Each directory in the /extensions folder of this repository contains the source code for a Firebase Extension with a README that explains how the extension works, including information about the APIs enabled, resources created, and the access granted to the extension.

List of Extensions

Want to install one of these? Visit each extension's linked README for installation instructions.

Optimize and transform images from your Cloud Storage buckets via a powerful HTTP API. Supports over 30 different image operations to optimize and manipulate your images.


Built and maintained by Invertase.

firebase-extensions's People

Contributors

cabljac avatar dackers86 avatar ehesp avatar pr-mais avatar salakar avatar yamankatby avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

firebase-extensions's Issues

Image Processing API => Skip Cache?

Hey not sure if this is the best place to reach out. Loving this extension but I am running into an issue with the caching.

Steps to Reproduce

  1. Upload file to Firebase Storage to users/userID/profile-pic.jpg
  2. Use invertase process api to get the image on the client
  3. Upload a new profile picture to users/userID/profile-pic.jpg
  4. Once again, use invertase process api to get the image on the client

Issue
I am getting back the original upload picture (from step 1) not the newer picture (from step 3). I believe this is because Invertase is caching the photos (which is great), but how can I skip/update the cache when I know that the picture has changed?

Potential Solution
Somewhere in the input could there be a bool parameter skipCache where Invertase would skip the cache and get the new image?
Or is there a different API other than GET /process that we can hit to let Invertase know the cache is invalid?

I hope this makes sense! Happy to provide more details & have been loving this extension -- thanks for all the hard work!

Issues escaping %2F in query params on url

I have my images in subfolders on GCS / firebase storage with URL pattern /bucket/o/<folder>%2F<subfolder>%2F<file>.

When I parse my operations with encodeURIComponent it escapes the %2F correctly as %252F which is sent to the cloud function.

In the cloud function error logs I can see that the %252F is replaced by / instead of expected %2F which results in an invalid URL.

Image Processing API => "Unable to fetch image from url..."

I am trying the basic example provided in the docs

async convertImg(url: string): Promise<string> {
    const operations = [
      {
        operation: 'input',
        type: 'url',
        url,
      },
      {
        operation: 'output',
        format: 'webp',
      },
    ];
    const ops = encodeURIComponent(JSON.stringify(operations));
    const reqOps = {
      method: 'GET',
      headers: {
        'Content-Type': 'application/json',
        'Access-Control-Allow-Origin': '*',
      }
    }
    const endpoint = `https://us-central1-**.cloudfunctions.net/ext-image-processing-api-handler/process?operations=${ops}`;
    return await fetch(endpoint).then((res) => res.json());
  }

The frontend returns this error

Access to fetch at 'https://us-central1-***.cloudfunctions.net/ext-image-processing-api-handler/process?operations=%5B%7B%22operation%22%3A%22input%22%2C%22type%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2F***.appspot.com%2Fo%2Fimages%252Fcms-images%252FScreenshot%25202023-03-28%2520at%25205.32.09%2520PM.png.png%3Falt%3Dmedia%26token%3D7c85c1a0-9c84-4b94-af76-182e48749a5a%22%7D%2C%7B%22operation%22%3A%22output%22%2C%22format%22%3A%22webp%22%7D%5D' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

google cloud logs show this error

Unable to fetch image from url "https://firebasestorage.googleapis.com/v0/b/habitat-commons-cms.appspot.com/o/images/cms-images/Screenshot 2023-03-28 at 5.32.09 PM.png.png?alt=media&token=7c85c1a0-9c84-4b94-af76-182e48749a5a", the url returned a non-successful status code of "400". The returned error was: Request failed with status code 400

Add background alpha or alpha operations?

Hi there!

Here is my little problem, for example I have a picture 256x256, I want to extend it to 512x512, so I'm using next operation

{
  operation: 'extend',
  left: 128,
  right: 128,
  top: 128,
  bottom: 128
}

It works well! For background, I can use background: #000 to make it any color, but I want to make it transparent, I have tried to use background: rgba(0, 0, 0, 0) or background: 'transparent' and it also works well .. but only with png source images, if I'm using jpg and same background parameters then background become black by default

Can you make it transparent too? No matter what is the source images, if you extend it you can set background: 'transparent' and got a transparent background (of course if your output compatible with alpha channel)


If it is not, so .. I can always do another one operation before extend (convert image to png first) but it takes extra request which I dont want to do in optimization purposes

[storage-image-processing-api] Calling Image Processing API with Cloud Functions for Firebase client SDKs

Given the working url:

"https://[my project id here].cloudfunctions.net/ext-image-processing-api-handler/process?operations=${jsonEncode(operations)}"

I didn't succeeded to write the equivalent call with Flutter Firebase Cloud Functions for Firebase client SDK. I tried variation of this snippet with no avail:

FirebaseFunctions.instanceFor()
        .httpsCallable("ext-image-processing-api-handler")
        .call({"operations": jsonEncode(operations)});

What is the way to call Image Processing API from Cloud Functions for Firebase client SDKs ?

peerDep issue

Error: node_modules/@invertase/image-processing-api/dist/types/types.d.ts:2:19 - error TS2307: Cannot find module 'sharp' or its corresponding type declarations.

2 import sharp from 'sharp';

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.