heroku file upload in php - heroku

I'm wondering for long period of time for making an app in facebook with heroku server. Actually my app dynamically generates image via php. But heroku wont allow allow me for image generation. Can some one explain me how to solve it or recommend any other free server like heroku?

I don't really know what your question is, since you didn't post any specifics or code samples, but I'm betting your issue is with Heroku having a read-only filesystem. If you want your app to be able to create/store/manipulate files, you should be using external storage. I use Amazon S3 with Heroku to store images for my Rails apps and it works great. Google "Heroku s3" and you should find a wealth of information.
More info on the filesystem restraints: https://devcenter.heroku.com/articles/read-only-filesystem

Related

Question about deploying a Shopify app to Heroku

I have question about Shopify app development and the deployment process.
I've used the getting started guide here, and I have an app that works fine when I use npm run dev and view the app in the store admin.
However, of course, once I stop the server from running, the app is no longer accessible.
I believe I need to deploy the app to Heroku (or something similar) in order to have it work in a non-development environment.
It doesn't seem like there is much guidance online from Shopify about the best way to go about this.
Does anyone know what steps I need to take in order to deploy my app to Heroku, so that I can use the app in by test store on another device?
It seems like every guide online stops JUST BEFORE explaining this process and I can't figure out why! I have tried everything online but nothing has worked:
Adding the code to Github and connecting it to Heroku
Using Docker
Any help is appreciated. Thank you!
You have zero obligations to use Heroku. If you have an IP address dedicated to your house, you could host the App using your house. If you co-locate your own server at an Internet business, and they give you IP addresses you can use that. If you wanted to use Amazon directly, you could use EC2. If you wanted to use Linode, or Azure, or any other cloud service, feel free! It is up to you!
Using Heroku (built on AWS) is traditional only in the sense that it is the original easy peasy hosting in the cloud service. Play with Heroku by reading Heroku-specific documentation or hosting information. This has nothing to do with Shopify. Shopify only mentions Heroku because traditionally, developers used it. No other reason.
If you want to learn how to use Heroku, 100% there are blog posts within easy reach for you to study and learn from.

Using Heroku for production

This help site (http://www.howtoinstallghost.com/how-to-install-ghost-on-heroku/) says that "Heroku should not be used for production!". What could the possible reasons for them saying this be?
I just want to set up a simple blog.
Thank you in advance.
From the same page;
Why do you only recommend Heroku for testing?
If you upload any images to your Ghost blog hosted on Heroku they will eventually be lost because of the ephemeral filesystem. There is no warning about this so we do not currently recommend anybody to use Heroku.
In other words, since any files you write to the file system at Heroku may go away at any time (and is not shared between instances of the blog if you try to scale out), you may lose all uploaded pictures at any time (once a month/once a minute, who knows) and need to upload them again.

Upload videos to Amazon S3 using ruby with sinatra

I am building an android app which has a backend written on ruby/sinatra. The data from the android app is coming in the form of json data.
The database being used is mongodb.
I am able to catch the data on the backend. Now what I want to do is to upload a video on Amazon S3 being sent from the android app in the form of byte array.
I also want to store the video in a form of a string in the local database.
I have been using carrierwave, fog and carrierwave-mongoid gems but didn't have any luck.
These are the some blogs I followed:
https://blog.engineyard.com/2011/a-gentle-introduction-to-carrierwave/
http://www.javahabit.com/2012/06/03/saving-files-in-amazon-s3-using-carrierwave-and-fog-gem/
If someone could just guide me with how to go about it specifically with sinatra and mongodb cause that's where I am facing the main issue.
You might think about using AWS SDK for Android to directly upload to S3 so that your app server thread doesn't get stuck while an user is uploading a file. If you are using a service like Heroku you would be paying extra $$$ just because your user had a lousy connection.
However in this scenario;
Uploading to S3 should be straight forward once you have your mounting in place using carrierwave.
You should never store your video in the database as it will slow you down! DBs are not optimised for files, OSs are. Video is binary data and cannot be stored as text, you would need a blob type if you want to do this crime.
IMO, uploading to S3 is good enough as then you can use Amazon cloudfront CDN services to copy and distribute your content in a more optimised way.

Saving third-party images on third-party server

I am writing a service as part of which a user chooses an image from a url (not my domain) and later he and others can view that image.
I need to save this image to a third party server (S3).
After a lot of wasted time I found I can not do it from the client side due to security issues (I can't get the third party image data and send it from the client side without alerting the client, which is just bad)
I also do not want to do the uploading on my server because I run Rails on Heroku and the workers expansive.
So I though of two options:
use something like transloadit.com,
or write a service on EC2 that will run over my db, find where the rows where the images are not uploaded and upload them.
I decided to go for the EC2 and S3 because the solution i am writing is meant for enterprise and it seems that it will sound better as part of the architecture when presented to customers.
My question is: what is the setup i need so I can access the Heroku db from an external service?
Any better ideas on how to solve this?
So you want to effectively write a worker, but instead of doing it on Heroku you want to do it on EC2? That feels like more work.
As for the database, did you see the documentation? It shows how to get the URL.
PS. Did you not find it in the docs?

No permanent filesystem for Heroku?

The app I am currently hosting on Heroku allows users to submit photos. Initially, I was thinking about storing those photos on the filesystem, as storing them in the database is apparently bad practice.
However, it seems there is no permanent filesystem on Heroku, only an ephemeral one. Is this true and, if so, what are my options with regards to storing photos and other files?
It is true. Heroku allows you to create cloud apps, but those cloud apps are not "permanent" - they are instances (or "slugs") that can be replicated multiple times on Amazon's EC2 (that's why scaling is so easy with Heroku). If you were to push a new version of your app, then the slug will be recompiled, and any files you had saved to the filesystem in the previous instance would be lost.
Your best bet (whether on Heroku or otherwise) is to save user submitted photos to a CDN. Since you are on Heroku, and Heroku uses AWS, I'd recommend Amazon S3, with optionally enabling CloudFront.
This is beneficial not only because it gets around Heroku's ephemeral "limitation", but also because a CDN is much faster, and will provide a better service for your webapp and experience for your users.
Depending on the technology you're using, your best bet is likely to stream the uploads to S3 (Amazon's storage service). You can interact with S3 with a client library to make it simple to post and retrieve the files. Boto is an example client library for Python - they exist for all popular languages.
Another thing to keep in mind is that Heroku file systems are not shared either. This means you'll have to be putting the file to S3 with the same application as the one handling the upload (instead of say, a worker process). If you can, try to load the upload into memory, never write it to disk and post directly to S3. This will increase the speed of your uploads.
Because Heroku is hosted on AWS, the streams to S3 happen at a very high speed. Keep that in mind when you're developing locally.

Resources