使用AngularJS多部分的表单数据上传文件,谷歌云存储表单、上传文件、部分、数据

2023-09-14 00:24:57 作者:如此迷恋沵的微笑つ

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

我产生一个授权头令牌服务器端和使用进行身份验证。我可以成功上传图片使用邮差(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.