New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lifting with watch task in production results in timeout #6834
Comments
@Smoenybfan Thanks for posting! We'll take a look as soon as possible. In the mean time, there are a few ways you can help speed things along:
Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly. For help with questions about Sails, click here. |
Assuming you have succeeded in uploading the files to your sails server https://github.com/mikermcneil/ration/blob/master/api/controllers/things/upload-thing.js you need to create another action responsible for downloading the files to the browser, check this -> https://github.com/mikermcneil/ration/blob/master/api/controllers/things/download-photo.js in your ...
'GET /api/v1/things/:id/photo': { action: 'things/download-photo', skipAssets: false }, then in your view you can use: <!-- Depending on your structure -->
<div v-for="(thing, i) in things" :key="i">
<!-- ${thing.id} refers to the identity of the photo we uploaded via the action-->
<img :src="`/api/v1/things/${thing.id}/photo`"/>
<!-- or ${thing.imageSrc}, it depends -->
</div>
You don't need to be worried where your images are uploaded to, sails has so many skipper adapters to use and they are production ready - trust me. One more thing, checkout the Ration APP as it have helped me in the past to master sails - good luck |
Thank you for the quick response! I think you might have misunderstood me. My goal is to do the download explicitly without writing an action by using the download attribute of the anchor html tag <a href="assets/uploads/myfile.xlsx" download>Click to download</a> As far as I understand, there is a grunt task "watch" that observes the assets folder for any changes that happen there and if any happen, the tasks defined in the tasks/config/watch.js are executed. One of these tasks is the "syncAssets" task that would sync the assets and the .tmp folder. This would mean that any files I have uploaded successfully and stored in the assets folder would be synced to the .tmp folder and would then be available to the download anchor described above. That way, no action is needed and the file can be directly downloaded from the served assets. I got this working in development environment as the watch task is registered in the tasks/register/default.js Now I want to have this behavior too in production but when I register the "watch" task in tasks/register/prod.js, then sails is not able to lift anymore due to the timeout described above. Currently my workaround is to either copy the file manually from the assets folder to the .tmp folder or to write a download action as you described, but if possible I'd prefer to use the grunt task just as I already have in development. Also, I will check out the Ration APP once I've got some time on my hands, thank you. |
i don't know if this would work, have you tried to change your |
Node version: 11.10.1
Sails version (sails): 1.1.0
ORM hook version (sails-hook-orm): 2.1.1
Sockets hook version (sails-hook-sockets): 1.5.5
Organics hook version (sails-hook-organics): -
Grunt hook version (sails-hook-grunt): 3.1.1
Uploads hook version (sails-hook-uploads): -
DB adapter & version (e.g. sails-mysql@5.55.5): sails-mysql@1.0.1
Skipper adapter & version (e.g. skipper-s3@5.55.5): skipper-disk@0.5.12
In tasks/register/prod.js I want to add the 'watch' task to the array that shoud get registered. But if I do this, then lifting the app in production will result in a timeout. I've already set the hookTimeout to 1000000, but that did not help. Is it even possible to use the watch task in production?
I've seen issue #3894, but the answer was to up the timeout (did not help) and it is nearly three years old.
To demonstrate my use case: I want to upload files from a user and then save them in the filesystem in the assets folder. Now I also want to be able to access these files directly from the fronted via a "a href download" link. The problem is that when run in production, the assets folder does not get synced to the .tmp/public folder. For this I wanted to use the watch task.
The text was updated successfully, but these errors were encountered: