问题
How can I Upload images to my bucket on google cloud endpoint using angular4. I don't want to use nodejs because i don't want to use require in my angular project. Or is there an alternative to using require in angular4 .For example using import instead of require
回答1:
Use the Firebase SDK, it is using Google Storage of the GCP project you created (so you don't need to register to a new service)
https://firebase.google.com/docs/storage/web/start
回答2:
You can use the Javascript Google API Client Library to upload to GCS. There is an example of using this at https://github.com/googlearchive/storage-getting-started-javascript
However you should be careful doing this: You will essentially have to give your users permissions on your bucket. This may result in them being able to run up large storage charges for you, accessing other users objects or deleting your data.
A safer alternative is to make the calls from GCS to a server-side application (perhaps on App Engine) on behalf of the client (perhaps returning signed urls to give limited permissions to the client) As Jo Jo points out, Firebase makes this easy for you, doing much of the work.
来源:https://stackoverflow.com/questions/45906257/uploading-image-to-bucket