{"id":24510069,"url":"https://github.com/reriiru/python-resumable","last_synced_at":"2025-04-14T08:11:04.653Z","repository":{"id":57457485,"uuid":"105334407","full_name":"Reriiru/python-resumable","owner":"Reriiru","description":"Python hookups for ResumableJS","archived":false,"fork":false,"pushed_at":"2017-10-18T01:29:50.000Z","size":28,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T19:50:23.659Z","etag":null,"topics":["flask","resumable","resumable-upload","resumablejs"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Reriiru.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-30T02:27:33.000Z","updated_at":"2022-11-05T21:31:37.000Z","dependencies_parsed_at":"2022-09-11T05:04:21.957Z","dependency_job_id":null,"html_url":"https://github.com/Reriiru/python-resumable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reriiru%2Fpython-resumable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reriiru%2Fpython-resumable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reriiru%2Fpython-resumable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reriiru%2Fpython-resumable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Reriiru","download_url":"https://codeload.github.com/Reriiru/python-resumable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248843867,"owners_count":21170492,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","resumable","resumable-upload","resumablejs"],"created_at":"2025-01-22T00:24:49.431Z","updated_at":"2025-04-14T08:11:04.624Z","avatar_url":"https://github.com/Reriiru.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Python-resumable\n\nWell, in order to explain what is Python-resumable we have to explain what is ResumableJS. ResumableJS is a JavaScript library providing multiple simultaneous, stable and resumable uploads via the HTML5 File API. And python-resumable is a universal hookup for resumablejs. We'd like to create an interface that works regardless of which framework you use.\n\nIt has a universal hookup, that takes chunks as base64 strings, and currently it has a Flask-specific hookup that takes Flask file objects. We'd like to add Pyramid and Django hooks.\n\n## Instalation\n\nSimple as that:\n\n```\npip install python_resumable\n```\n\n## Usage\n\nIt's rather simple to use. It has to take 5 Resumable headers, your upload and tmp directory and file data as well.\n\nHere's a simple Flask example.\n\n```python\n\nfrom flask import Flask, request, jsonify\nfrom python_resumable import FlaskUploader\n\n\napp = Flask(__name__)\n\n@app.route('/uploads', methods=['GET'])\ndef check_status():\n    \"\"\"This route works with get checks from resumable\"\"\"\n\n    resumable_dict = {\n        'resumableIdentifier': request.args.get('resumableIdentifier'),\n        'resumableFilename': request.args.get('resumableFilename'),\n        'resumableTotalSize': request.args.get('resumableTotalSize'),\n        'resumableTotalChunks': request.args.get('resumableTotalChunks'),\n        'resumableChunkNumber': request.args.get('resumableChunkNumber')\n    }\n\n    resumable = FlaskUploader(resumable_dict,\n                              '/home/user/uploads',\n                              '/home/user/tmp',\n                              request.files['file'])\n\n    if resumable.chunk.exists() is True:\n        return jsonify({\"chunkUploadStatus\": True})\n\n    return jsonify({\"chunkUploadStatus\": False}), 204\n\n\n@app.route('/uploads', methods=['POST'])\ndef upload_file():\n\n    resumable_dict = {\n        'resumableIdentifier': request.form.get('resumableIdentifier'),\n        'resumableFilename': request.form.get('resumableFilename'),\n        'resumableTotalSize': request.form.get('resumableTotalSize'),\n        'resumableTotalChunks': request.form.get('resumableTotalChunks'),\n        'resumableChunkNumber': request.form.get('resumableChunkNumber')\n    }\n\n    resumable = FlaskUploader(resumable_dict,\n                              '/home/user/uploads',\n                              '/home/user/tmp',\n                              request.files['file'])\n\n    resumable.upload_chunk()\n    \n    if resumable.check_status() is True:\n        resumable.assemble_chunks()\n        return jsonify({\"fileUploadStatus\": True,\n                        \"resumableIdentifier\": resumable.repo.file_id})\n\n    return jsonify({\"chunkUploadStatus\": True,\n                    \"resumableIdentifier\": resumable.repo.file_id})\n```\n\nWell... As simple as it could actually get with Resumable.\n\n## Mini-reference\n\nThis package provides you with two usable classes -- Uploader and FlaskUploader. They are essentially identical, except for the type of chunk-data they take.\n\nArguments on creation:\n\n* ```resumable_dict```: contains Resumable data in a dictionary form, namely: ```'resumableIdentifier', 'resumableFilename', 'resumableTotalSize', 'resumableTotalChunks', 'resumableChunkNumber'```\n* ```upload_dir```: contains path to your final directory where the file will be assembled.\n* ```tmp_dir```: contains path to temporary directory, where it will store the chunks.\n* ```chunk_data```: contains data transfered with the chunk. Uploader takes generic b64 strings, FlaskUploader takes Flask file objects.\n\nAttributes:\n\n* ```Chunk```: Stores chunk-related data. For full inforamtion -- refer to the full reference.\n* ```Repository```: Stores data related to the end file. For full inforamtion -- refer to the full reference.\n\nMethods:\n\n* ```upload_chunk```: If chunk already exists returns False, else saves chunk to ```tmp_dir/resumableId/chunk_name``` and returns True.\n* ```check_status```: If all chunks are in tmp returns True, else returns False.\n* ```assemble_chunks```: Assembles all of the chunks in your ```upload_dir```. If filename is not specified uses resumableFilename.\n* ```cleanup```: Deletes all the data from ```tmp_dir/resumableId```.\n\n\nFull reference can be found in docstrings.\n\n\n## Links\n\n* [ResumableJS](http://www.resumablejs.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freriiru%2Fpython-resumable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freriiru%2Fpython-resumable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freriiru%2Fpython-resumable/lists"}