如何使用Java API复制文件

时间:2013-06-04 16:34:45

标签: scala google-cloud-storage

我有以下代码:

def copyFile(bucket:String, filename:String, newFilename:String) {
    getFile(bucket, filename) match {
      case Some(storageObject) => storage.objects().copy(bucket, filename, bucket, newFilename, storageObject).execute()
      case None => throw new FileNotFoundException("file " + filename + " not found")
    }
  }

代码找到文件,所以我知道bucket,filename和storageobject是有效的。对于我的测试,newFilename只是“test123”,因此不确定这是怎么回事。另外,为什么该方法需要storageObject?似乎拥有现有的和新的存储桶和文件名就足够了。不幸的是,错误消息实际上是不透明的。

400 Bad Request
{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Invalid argument.",
    "reason" : "invalid"
  } ],
  "message" : "Invalid argument."
}
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Invalid argument.",
    "reason" : "invalid"
  } ],
  "message" : "Invalid argument."
}

0 个答案:

没有答案