Uploading Image to Bucket

痞子三分冷 提交于 2019-12-24 11:01:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!