How to fetch newly added images from VM in google cloud platform? - image

When I add images it is stored inside google cloud platform VM correctly.
But I am not able to fetch newly added images in my website.
If I redeploy project with newly added images in assets folder it is showing correctly.
I have verified there is no mistake on frontend or backend side.
Is it not possible to get live image update with VM?
Edit:
I have used Vue.js.
I am storing images inside src/assets folder.
When I save images in my website it is saved at src/assets folder.
I think it can only access things in dist folder after build.
Can you suggest where should I save my file?

I'm making an educateg guess it's some cache issue.
Instead of putting your image files inside the VM you can try storing them in a bucket that's accessible to public. The downside is that it can serve only static files (no PHP or anything).
You have to configure your load balancer to forward all your.domain.com/images/ requests to the bucket but that's actually quite easy. Have a look at my answer asking for such configuration.

Related

Move file from laravel server to Nuxt server

I have two separate project, laravel and nuxt;
i want to, when i upload file from the laravel, it'll be stored on static folder of the nuxt project. Is there any way for that?
For that, you'll need to send your file upload to a CI that will inject it into the Nuxt project, and rebuild the whole Nuxt app.
Also, remember that static is not bundled via Webpack.
Meaning that it will be shipped raw: if it's uploaded while not being properly optimized, it'll be shipped as is (would be better suited into an /assets directory but still >> build time for the whole project required here).
Even hosting it on your Laravel server is more worth at this point.
TLDR: it's not worth to send it to Nuxt's static directory.
I recommend hosting it on a CDN or alike.

Laravel Vapor - Assets (logo) on maintenance mode page

According to the docs we are able to put a 503.html document inside the root of our Laravel project.
You may customize the maintenance mode splash screen for your application by placing a 503.html file in your application's root directory.
I would however love to be able to put one or more assets on this page (for example our Logo) to make this page better more personal. Laravel Vapor automatically uploads your static assets to cloudfront, which is not a problem if you're using the asset() helper. However, are there any solutions already being made? I can't find any.
Is there anyone who has created a solution to make this happen?
With Vapor every time you deploy all the assets get a new cloudfront url. This is mostly fine for js and css which we change often. Images, logos etc do not change much.
Better to make another bucket on aws and hard code the path the image file in your 503. Doesn't need to be deployed every time. Your users browsers can cache it for as long as you set it in the bucket.
I'd like Vapor to only change asset urls if the files have changed but so far that is not the case.

Storing images in storage folder of laravel, and fetching it by a http request is not working

I have deployed laravel application in heroku. I am storing images in storage folder of laravel and trying to fetch it by defining a route. It was working well on local, but when i trying to do the same on server, then its not showing the images. I thought that storage folder is inside the laravel, so it should work fine, but its not working.
Can i store images in public folder by creating a named folder "gallery" inside that and put that gallery folder in gitignore. so will the gitignore folder be vanished when i will push the laravel project again?
Other options are using another file system. Most of them are paid, so i was thinking to save the images in database, is that the good idea or i should move to files only.
First of all, the storage directory should have right permission.
You should create a symbolic link from public/storage to storage/app/public.
Create the symbolic link:
php artisan storage:link
You cannot save images in database, only their names or links etc. I implemented the same thing you did by naming the files to their path and storing that to the database and then using it to fetch the data from folder on sever

Uploading files to a Heroku website connected to GitHub?

I'm making a pretty simple website and I have a feature that allows users to upload an image for their profile which is then saved in an uploads directory.
It seems to work fine, however when I push a new local version of the site out I lose all the uploaded files. I'm not exactly sure where Heroku stores them, is there a way I can push those to GitHub or another solution?
It seems like you want data from heroku app to your repository, if i understood your question correctly. Then try this:
https://blog.heroku.com/push_and_pull_databases_to_and_from_heroku
Heroku's filesystem is ephemeral. If you want to store user uploaded content, you need to use something like S3 to store the files.

how to build image service website with sails.js

I am using sails.js to build an image service website. There are lots of images need be shown on the webpage. And the website will allow users to upload images as well. If I put it all images under assets folder, they will be copied to .tmp/public everytime when i restart the sails server . it will be very slow. Does anyone have an idea where should i put .Should I write a route rule to handle this? thanks.
/assets are for your static contents (like css, frontendjs, ...).
If you have a lots of images you should place them in one folder of your server and write a route for showing it.
Or better: Use some Cloud-Hosting like amazonS3 or imageShack.
Example for middleware:
1.) create a file "express.js" in config/
2.) Put this code into the file and change to the right path (routing + your local folder):
module.exports.express = {
customMiddleware: function(app){
app.use('/images', require('../node_modules/sails/node_modules/express').static('/User/yourfolder'));
}
}

Resources