Canvas API apparently doesn't like big images
djplaner opened this issue · comments
David Jones commented
Word docx appears to bork at big images (e.g. first learning module from 1499EDN).
They just disappear -- when converted to HTML this is working, but when added to Canvas, it disappears
Cause is due to Canvas RCE deleteing base64 content
- is there an error being generated and which can be handled?
- is there a limit on the API
- is there a workaround for the limit
- ??? if not, what's the solution - warning, create image??
Solution
- Use Javascript to upload file
- Figure out python to upload a file
David Jones commented
Converting base64 images into files saved on Canvas files area
Keep Mammoth base64 images as is in WordConverter. Creating the module would need to
- detect any base64 images
- Convert to images and save to Canvas files
- UPdate the html to point to the URLs of the image files that were saved
The image URL is the full file url with "/preview" on the end
David Jones commented
Uploading a file via Canvas API
- ucfopen/canvaspi upload class
- OIT canvas git - docs/examples using CURL to explain the uploading files process - but uses a file on the file structure
- Canvas Dev and Friends - has ]lesson on file uploads](https://canvas.instructure.com/courses/785215/assignments/2241276?module_item_id=4783530)
ufcopen/canvasapi
This works fine it's process is
- start - open the file into python file handle
- request_upload_token
- makes POST request to URL
- "name" and "size" are the parameters
- upload
- passed the response from request_upload_token
- checks response for "upload_url" and "upload_params" if not there - there's an error
- generates a new request using the upload_url and the upload_params
David Jones commented
Implement trial run
- Create HTML page with javascript in it that communicates with Canvas API
- Get it to upload a text file
- Get it to upload a base64 image