{"record":{"id":"c9a4f2e9c74f2e3b","repo":"instructure/canvas-lms","slug":"todo-support-raw-files","errorCode":null,"errorMessage":"TODO: support raw files","messagePattern":"TODO: support raw files","errorType":"exception","errorClass":"Canvadocs::Error","httpStatus":null,"severity":"error","filePath":"lib/canvadocs.rb","lineNumber":69,"sourceCode":"    end\n\n    # -- Documents --\n\n    # Public: Create a document with the file at the given url.\n    #\n    # obj - a url string\n    # params - other post params\n    #\n    # Examples\n    #\n    #   upload(\"http://www.example.com/test.doc\")\n    #   # => { \"id\": 1234, \"status\": \"queued\" }\n    #\n    # Returns a hash containing the document's id and status\n    def upload(obj, extra_params = {})\n      params = if obj.is_a?(File)\n                 { file: obj }.merge(extra_params)\n                 raise Canvadocs::Error, \"TODO: support raw files\"\n               else\n                 { url: obj.to_s }.merge(extra_params)\n               end\n\n      raw_body = api_call(:post, \"documents\", params)\n      JSON.parse(raw_body)\n    end\n\n    # Public: Delete a document.\n    #\n    # id - a single document id to delete\n    #\n    def delete(id)\n      api_call(:delete, \"documents/#{id}\")\n    end\n\n    # -- Sessions --\n","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/lib/canvadocs.rb#L51-L87","documentation":"Canvadocs#upload accepts either a URL string or a File object, but the File branch is unimplemented: it immediately raises Canvadocs::Error \"TODO: support raw files\" before any API call. Only URL-based submissions are supported by this client method.","triggerScenarios":"Calling canvadocs_api.upload(file_object) with an actual File/IO object; the raise happens inside the obj.is_a?(File) branch.","commonSituations":"Developers attaching an uploaded attachment's IO stream directly instead of its authenticated public/preview URL; writing custom preview integrations that read from disk.","solutions":["Pass a URL string instead of a File — e.g. the attachment's public download or a pre-signed S3 URL — via upload(url, extra_params).","Upload the raw bytes to S3 (or other host) yourself and give Canvadocs the resulting URL.","If you need raw file support, patch upload to use a multipart POST, or upgrade to a canvadocs client version that supports it."],"exampleFix":"// before\ncanvadocs.upload(File.open(path))\n// after\nurl = Attachment.new.tap { |a| a.uploaded_data = file }.public_download_url\ncanvadocs.upload(url)","handlingStrategy":"validation","validationCode":"# ruby\nobj.is_a?(String) or raise ArgumentError, \"canvadocs upload requires a URL, not a File\"","typeGuard":null,"tryCatchPattern":"begin\n  canvadocs.upload(obj)\nrescue Canvadocs::Error => e\n  raise \"use a URL: #{e.message}\" if e.message.include?(\"raw files\")\nend","preventionTips":["Always upload bytes to S3 first and hand Canvadocs a URL.","Assert the argument is a String URL before calling upload.","Wrap upload in a helper that converts Attachment objects to URLs."],"tags":["canvadocs","unimplemented","file-upload"],"backgroundTag":"method-not-implemented","analyzedSha":"1c9f0bb8013ed69c4f2efe11fd483025469b7e6c","analyzedAt":"2026-09-15T20:33:18.891Z","contentChangedAt":"2026-09-15T20:33:18.891Z","schemaVersion":2},"datasetVersion":"2026-09-23T02:17:17.105Z"}