Git Product home page Git Product logo

Comments (4)

thetutlage avatar thetutlage commented on August 28, 2024 1

Yup. Actually, we shouldn't be saving URL in the database at all and always compute it at runtime. Only the name and other meta data should be saved

from attachment-lite.

thetutlage avatar thetutlage commented on August 28, 2024

Can you please share some code, with the actual output you get and the expected output?

from attachment-lite.

aungpyaekyaw avatar aungpyaekyaw commented on August 28, 2024

Hi, Thank you for the reply.

The visibility of my s3 config is set to private. So when I create a new model with preComputeUrl option, the attachment file url will be signed according to documentation.

It stored like the following in database.

{"url": "https://s3.ap.amazonaws.com/xxxx/cl2fx7fpe0003jj796udk1k6w.png?signed-params****", "name": "cl2fx7fpe0003jj796udk1k6w.png", "size": 834039, "extname": "png", "mimeType": "image/png"}

I can access the resource with the above pre-signed url. The problem is when the pre-signed url expired, attachment-lite is still returning the same pre-signed url and the resource is no longer available..

from attachment-lite.

ndianabasi avatar ndianabasi commented on August 28, 2024

I think the issue is from here:

/**
     * Self compute the URL if "preComputeUrl" is set to true
     */
    const fileVisibility = await disk.getVisibility(this.name)
    if (fileVisibility === 'private') {
      this.url = await disk.getSignedUrl(this.name)
    } else {
      this.url = await disk.getUrl(this.name)
    }

and

 /**
   * Returns the signed URL for the file. Same as "Drive.getSignedUrl()"
   */
  public getSignedUrl(options?: ContentHeaders & { expiresIn?: string | number }) {
    return this.getDisk().getSignedUrl(this.name, options)
  }

We might need to re-generate the signed URL when when the model is fetched.

from attachment-lite.

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.