Using SoundManager2 to create a non downloadable playlist - google-app-engine

Currently I am trying to develop a Music streaming service: using SoundManager2 for streaming. I am using Google App engine to do the same. Music files are stored in Google Cloud Storage Buckets.
After completion of each song I would do an ajax query to fetch the url of the next playable song.
But while doing so I expose the direct URL to the .mp3 file and I am able to download the same thorough the URL (with a little help from Chrome Developers Tool).
How can we stop the song from getting downloaded or do some thing like SoundCloud where the URL is not getting identified in Developers tool?

Related

Upload big files into S3 from React

I'm playing around making a video platform (for fun), I currently have 3 big pieces: a front end written in ReactJS, a backend written in NodeJS and a filesystem to store user media in digital ocean spaces (s3 bucket).
I want to keep this project lightweight and as it is practice for me I don't want to use a library that does everything for me. It's just an architecture question.
I already implemented a way for a user to upload an image on the backend (it uploads binaries from FE to the BE and in there it checks that everything is ok and then uploads to the filesystem). I also have an endpoint to stream the video from the filesystem, which works fine.
Now I am trying to do it for videos, but I have a dilemma, if I do the same as I do for images I will have to upload it first to the BE and then to the filesystem and AFAIK that's really inefficient.
Would it be a better idea to put the video upload directly on the Front end and then store the uploaded URL of the video into the DB? And if that is the case how can I make the S3 connection secure? Not exposing S3 bucket information.

How can I upload files to my S3 bucket from my React app without a backend?

I am creating a web app using React where the user can upload files to a folder in my S3 bucket. This folder will have a unique passcode name. The user (or someone else) can use this passcode to retrieve these files from the S3 folder. So basically there is no login/authentication system.
My current issue is how do I safely allow read/write access to my S3 bucket? Almost every tutorial stores the access keys to the client code which I read is very bad practice but I also don't want to create a backend for something this simple. Someone suggested presigned URLs but I have no idea how to set that up (do I use Lambda? IAMs?). I'm really new to AWS (and webdev in general). Does anyone have any pointers on what I could look into?
do I use Lambda? IAMs?
The setup and process if fully explained in AWS blog:
Uploading to Amazon S3 directly from a web or mobile application

React Native Upload to YouTube

I am trying to upload a video that I take locally using react native camera and then send it to youtube for processing and then want to display that video on a react.js web dashboard.
We have tried using fetch-blob to upload the video and cloud firestore to store the video. We are not sure at a high level on how to go about the uploading to youtube. I know there is upload docs, however can we physically go about uploading straight from our react-native project to youtube, or would we have to upload to a database such as firebase and then use a cloud function to send it to youtube? Has anyone attempted this? The other alternative is that we can upload to S3 and then use AWS cloudstream to play back but that seems like overkill if there is a simple youtube upload that we can use. Do we have to authenticate a user to youtube before it would work? We do not want anyone having to log into a google account. We are hoping just to have an application created with youtube that we can upload to our channel.
Thank you!
Answer
You can absolutely upload a video to YouTube in many different ways. You mentioned a few options and I will line out how those could work for you.
Do we have to authenticate a user to youtube before it would work?
You will have to authenticate to YouTube in order to upload to a YouTube account. You could very well have one account for your app to use and when your users make videos the app could upload them directly to that account. I do highly advise against that though. Google is not very forgiving and the second someone uploads something to violate Google Policies I suspect you will be banned.
That leaves me to believe the best way here would be to use Auth0 to authenticate users and upload to their accounts. Otherwise maybe look into other options.
Possible Options
Option 1
It might be possible to upload all the videos to one YouTube account and make them all private. Then retrieve those videos and play them on your own site. Possibly something like that could work but it is probably a long shot. That could at least keep you from getting banned because of a user violating Google Policies.
Option 2
Another option would be to make one YouTube account. Save the videos to your server when the users creates them from your mobile application. Then have a waiting period for the video to post to YouTube in order for you and your team to have time to approve them.
At least this way you can use YouTube and have one account, but not take the chance of any repercussions from the videos people are posting.
Problem
How to upload a video from your mobile app using React Native to youtube.com
Solution 1
Upload straight from React Native. You can Use the Google APIs to upload directly to youtube. Google has an extensive API. You will have to create a Google API account and make sure to activate the APIs you want to use. Here is some information I found using the Google Javascript API to work with Youtube.
If you go to this link you can see some information on the scopes of this API.
Here is one scope mentioned on that page.
https://www.googleapis.com/auth/youtube.upload
Using Gogoles APIs you can upload videos directly to the youtube account.
Solution 2
The second solution is to post the video to your server, then once it hits the server use some other server side language to interact with Google's API. This could come in handy for other reasons. Like if you are better with a language other than JavaScript. For example Python might be your favorite language. In that case here is a Python Github repo that does just what your trying to do.
You could very well implement the repo mentioned above to your server and post the video you create from your phone to the server. Allowing the Python script to handle posting the video to YouTube.
Side Note
I do not think Firebase or really any database is necessary for the task you are trying to accomplish. Unless there are other requirements to your problem you have not mentioned.

How to upload image to Google Cloud Storage with GAE/Cloud Endpoints API method

Does anyone have an example of a GAE/Cloud Endpoints API method (in Java) that can take in an image from an Android app and upload it to Google Cloud Storage?
I cannot seem to find any samples on how to do this but it is possible from what I understand.
EDIT:
The tutorial here shows how to add a dependency to google app engine in eclipse and upload/download an image to Google Cloud Storage. Is it possible to do this with Cloud Endpoints somehow..? After all, they are both Google App Engine.
I want to offload as much of the upload/download code into my Cloud Endpoints API method(s), rather than coding everything inside of Android. This would allow me to reuse my Cloud Endpoints API on other clients.
More info I found: https://developers.google.com/api-client-library/java/apis/storage/v1#sample
Looks like this is the gradle dependency for the cloud endpoints backend?:
dependencies {
compile 'com.google.apis:google-api-services-storage:v1-rev66-1.21.0'
}
EDIT:
You should use this dependency inside cloud endpoints:
compile 'com.google.appengine.tools:appengine-gcs-client:0.5'
You can upload file to Google Storage using Json Api
You may or may not want to store file metadata to datastore thru Endpoints.
You may or may not want to authenticate your users thru Endpoints before give them possibility to store files to Storage.
What I want to say is that Storage / Endpoints / Datastore are three different things and you don't required to use them all together.
Useful link: https://github.com/pliablematter/simple-cloud-storage
You cannot directly upload (large) files to an Endpoints API method but instead need to receive them using the blobstore (or GCS) (https://cloud.google.com/appengine/docs/python/blobstore/ ). This requires the following:
Setup on your server a blobstore upload handler (which is just a regular webapp2 handler).
Expose an Endpoints method that calls blobstore.create_upload_url(), and then returns the upload URL to your App.
Within the App, upload the picture to that upload URL; the file will then be accessible within your upload handler, where you can move it to GCS, Datastore or somewhere else.
Solution : https://github.com/thorrism/GoogleCloudExample
Enable Google Cloud Storage : => https://console.developers.google.com/apis
Generate and download a key P12 : => https://console.developers.google.com/iam-admin/iam
Create a folder named "assets" and place there your key :
=> app/src/main/assets/"yourKey.P12"
For everyone can access your uploaded file reading do not forget to add the permissions on your Bucket

Is there a size limit to upload file using webapp2?

I am using appengine and writing my server code in python using webapp2. I am trying to upload video files from browser and save it to Google cloud storage. I use the form element in my HTML and webapp2 handler on server side to upload the file from browser. It works for files of smaller size, but when I try to upload a video file greater than 100MB, the browser throws the blow error
This webpage is not available
ERR_CONNECTION_RESET
I am unable to debug this on server side as it doesn't hit the post method.
Is there a config parameter in web app 2 that can be modified to upload files of greater size?
Any inputs is greatly appreciated.
App Engine has a limit of 32MB on all requests. You should upload your files directly to Google Cloud Storage, not through your server. This will also save you a lot of instance time.
EDIT: As Alex mentioned, signed URLs is a great way to let users upload and download files directly from GCS.

Resources