使用AngularJS多部分的表单数据上传文件,谷歌云存储 [英] Upload file to Google Cloud Storage using AngularJS multipart form data

查看:229
本文介绍了使用AngularJS多部分的表单数据上传文件,谷歌云存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从使用的 https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload#multipart

我产生一个授权头令牌服务器端和使用进行身份验证。我可以成功上传图片使用邮差(<一个href=\"https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en\" rel=\"nofollow\">https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en)通过在'二进制'字段的图像连接。

I generate an 'Authorization' header token server side and use that for authentication. I can successfully upload the image using postman (https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en) by attaching the image in the 'binary' field.

我一直在使用这种jsfiddle.net/JeJenny/ZG9re/小提琴尝试手动上传,但它的返回我的400错误的请求错误,我已经检查了所有的头字段,他们似乎都不错。

I've been using this jsfiddle.net/JeJenny/ZG9re/ fiddle to try manual upload but it's returning me 400 bad request error and I've checked all the header fields and they seem to be all good.

如果任何人有使用AngularJS上传图片到谷歌云存储有经验,我想知道。

I was wondering if anyone has had experience in uploading images to Google Cloud Storage using AngularJS.

感谢

推荐答案

我已经成功上传通过BLOBSTORE AngularJS文件。当您创建上传网址,您可以设置Cloud Storage值名称。下面是一个Java的例子:

I have been successfully uploading files with AngularJS through BlobStore. When you create an upload URL, you can set the Cloud Storage bucket name. Here is a Java example:

String uploadUrl = BlobstoreServiceFactory.getBlobstoreService()
   .createUploadUrl("callback-path",
      UploadOptions.Builder.withGoogleStorageBucketName("bucket-name"));

上传成功后,您的回调URL被调用,你可以得到BLOB的名字。

After a successful upload, your callback URL is called and you can get the blob's name.

这篇关于使用AngularJS多部分的表单数据上传文件,谷歌云存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆