Comments (7)
This should not be closed, this was very confusing.
Based on this section of the docs
https://github.com/adonisjs/attachment-lite#pre-compute-on-demand
attachment-lite/src/Attachment/index.ts
Line 233 in 8144c36
Having to replicate the options of the decorator with preComputeUrls set to true is not ideal.
I would consider adding another function meant for computing on demand where a forced flag or something can be passed to computeUrl so it ignores the value of preComputerUrls.
I can provide a patch if that sounds like an acceptable approach.
from attachment-lite.
Looking for test file, you use setOptions method:
attachment-lite/test/attachment.spec.ts
Line 96 in 8144c36
If i set this on preCompute on demand methos, it works:
class User extends BaseModel {
public static async preComputeUrls(models: User | User[]) {
if (Array.isArray(models)) {
await Promise.all(models.map((model) => this.preComputeUrls(model)))
return
}
models.avatar?.setOptions({ disk: 'diskName', preComputeUrl: true }) // Only work if i replicate options of model, including preComputeUrl
await models.avatar?.computeUrl()
await models.coverImage?.computeUrl()
}
}
from attachment-lite.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from attachment-lite.
So far I am not sure what exactly this issue is about. Is it that preComputeUrl
option not functioning as documented or something else?
from attachment-lite.
So following the docs it's recommened to not set preComputeUrls to true on the decorator.
class User extends BaseModel {
@attachment({ preComputeUrl: false})
public avatar: AttachmentContract
}
class User extends BaseModel {
public static async preComputeUrls(models: User | User[]) {
if (Array.isArray(models)) {
await Promise.all(models.map((model) => this.preComputeUrls(model)))
return
}
await models.avatar?.computeUrl()
await models.coverImage?.computeUrl()
}
}
This function does not work as described. computeUrl
always returns early if preComputeUrl
is false or undefined. No URL's are computed.
I do not think this is a documentation issue, I would expect computeUrl
to always build the urls and having preComputeUrls
on the decorator to false/undefined shouldn't affect running the function on demand.
from attachment-lite.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from attachment-lite.
not stale
from attachment-lite.
Related Issues (20)
- Allow creation of attachments outside the context of a file sent via HTTP request HOT 1
- No mention on how to create column in database HOT 1
- Unavoidable errors when DB response is `null` HOT 1
- Pre-signed URL saved on model expired HOT 4
- 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
- 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
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.