Comments (4)
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.
Can you please share some code, with the actual output you get and the expected output?
from attachment-lite.
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.
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)
- Allow creation of attachments outside the context of a file sent via HTTP request HOT 1
- Is there a way to rename saved files? HOT 4
- Can I upload multiple files? HOT 1
- Pre compute URL with expiresIn option. HOT 2
- [Adonis Responsive Attachment] preComputeUrls dosn't work when using Database query HOT 2
- How to use Factory with a model that implements Attachment Lite? HOT 2
- attachementLite.setOptions should override @attachment options HOT 4
- Pre compute on demand not work HOT 7
- No mention on how to create column in database HOT 1
- Files in temp folder are not deleted after uploading to S3. HOT 1
- Ability to override serialize, prepare and consume options on attachment decorator HOT 2
- Model `save` function does not return the model anymore HOT 8
- `computeUrl` function not working without `preComputeUrl` config set HOT 6
- Image conversion after uploading HOT 5
- Attachment's name is undefined HOT 3
- Error: existingFile.setOptions is not a function
- preComputeUrl is giving out wrong URL
- V6 support HOT 1
- Unavoidable errors when DB response is `null` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from attachment-lite.