{"action":"created","issue":{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/591","labels_url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/591/labels{/name}","comments_url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/591/comments","events_url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/591/events","html_url":"https://github.com/chrsmith/google-api-java-client/issues/591","id":59525768,"number":591,"title":"MediaHttpUploader.upload() requires a known InputStreamContent size","user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/auto-migrated","name":"auto-migrated","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/Component-Media","name":"Component-Media","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/Milestone-Version1.13.0","name":"Milestone-Version1.13.0","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/Priority-High","name":"Priority-High","color":"ededed"},{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/labels/Type-Enhancement","name":"Type-Enhancement","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-02T18:44:41Z","updated_at":"2015-03-02T18:44:42Z","closed_at":"2015-03-02T18:44:41Z","body":"```\nVersion of google-api-java-client (e.g. 1.5.0-beta)?\n1.10.3-beta\n\nJava environment (e.g. Java 6, Android 2.3, App Engine)?\nJava 6\n\nDescribe the problem.\nIf you provide an InputStreamContent where you've not specified setLength(), \nand thus it defaults to -1 (unknown length), you get a precondition failed:\n\njava.lang.IllegalArgumentException\n\tat com.google.common.base.Preconditions.checkArgument(Preconditions.java:72)\n\tat com.google.api.client.googleapis.media.MediaHttpUploader.getMediaContentLength(MediaHttpUploader.java:315)\n\tat com.google.api.client.googleapis.media.MediaHttpUploader.executeUploadInitiation(MediaHttpUploader.java:333)\n\tat com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:252)\n\n\nHow would you expect it to be fixed?\n1) MediaHttpUploader.getMediaContentLength() should remove the precondition.\n2) MediaHttpUploader.executeUploadInitiation should \nsetUploadContentLength(null) (or if omitting that header doesn't work, there \nshould be an overload that allows a \"X-Upload-Content-Length: *\", which is how \nyou specify an unknown length to the upload service).\n3) MediaHttpUploader.setContentAndHeadersOnCurrentRequest should specify the \nContent-Range ending in * when getMediaContentLength() == -1. It also needs to \nchange its blockSize calculation in the case getMediaContentLength() == -1 to \ntry to read the whole block and if you reach the end of the stream, \nsetMediaContentLength() to be the appropriate value.\n4) I'm not sure this is required, but you may end up having to additionally add \nX-Upload-Content-Length: * in the setContentAndHeadersOnCurrentRequest until \nsuch time as you resolve the end of the stream. \n```\n\nOriginal issue reported on code.google.com by `nherr...@google.com` on 16 Aug 2012 at 5:17"},"comment":{"url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/comments/76776510","html_url":"https://github.com/chrsmith/google-api-java-client/issues/591#issuecomment-76776510","issue_url":"https://api.github.com/repos/chrsmith/google-api-java-client/issues/591","id":76776510,"user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"created_at":"2015-03-02T18:44:42Z","updated_at":"2015-03-02T18:44:42Z","body":"\n\nOriginal comment by `yan...@google.com` on 20 Aug 2012 at 12:15\n* Changed state: **Accepted**\n* Added labels: **Priority-High**, **Component-Media**\n* Removed labels: **Priority-Medium**"}}