Code Monkey home page Code Monkey logo

Comments (6)

Ketchupchh avatar Ketchupchh commented on May 30, 2024 1

Yeah, this should be fixed. In my testing it doesn't replace any images but just discards the new one and places the original in the tweet instead. I'll fix the issues you found in my PR as well, thank you. I'll contact ccrsxx about the username bug as well.

from twitter-clone.

ccrsxx avatar ccrsxx commented on May 30, 2024 1

Yup, but that's by design.

I made it so that when we upload the same image with the same alt, it will return the old image instead of creating the new image. It won't replace the old image with the new image tho.

This is the code:

try {
src = await getDownloadURL(storageRef);
} catch {
await uploadBytesResumable(storageRef, file);
src = await getDownloadURL(storageRef);
}

I did it to reduce the bandwidth usage on the storage.

But yeah, that's bad if you upload a different picture with the same alt, it'll return the old one.

I see that the bandwidth usage isn't that much, so I think replacing the alt to id is good idea now.

from twitter-clone.

ccrsxx avatar ccrsxx commented on May 30, 2024 1

Yup, that could be the solution. But for now, I''ll be using the randomly generated id.

from twitter-clone.

stanbar avatar stanbar commented on May 30, 2024

@Ketchupchh thank you!

from twitter-clone.

stanbar avatar stanbar commented on May 30, 2024

@ccrsxx Well, if you want to do this kind of optimisation I think that the better option would be to calculate a hash (e.g. sha256) of a file's content, and use that instead of a filename. That way, the same images with different names, would be stored only once.

from twitter-clone.

Related Issues (20)

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.