{"id":27966544,"url":"https://github.com/techery/chunk-uploader","last_synced_at":"2025-08-06T15:14:46.155Z","repository":{"id":75020258,"uuid":"21396462","full_name":"techery/chunk-uploader","owner":"techery","description":"Ruby gem for uploading files in chunks.","archived":false,"fork":false,"pushed_at":"2014-07-01T17:26:52.000Z","size":120,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":43,"default_branch":"master","last_synced_at":"2023-08-06T02:14:57.392Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/techery.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-01T17:25:18.000Z","updated_at":"2023-08-06T02:14:57.393Z","dependencies_parsed_at":"2023-02-22T18:01:04.042Z","dependency_job_id":null,"html_url":"https://github.com/techery/chunk-uploader","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techery%2Fchunk-uploader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techery%2Fchunk-uploader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techery%2Fchunk-uploader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techery%2Fchunk-uploader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/techery","download_url":"https://codeload.github.com/techery/chunk-uploader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252949432,"owners_count":21830187,"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":[],"created_at":"2025-05-07T20:19:25.808Z","updated_at":"2025-05-07T20:19:26.338Z","avatar_url":"https://github.com/techery.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ChunkUploader\n\nRuby gem for uploading files in chunks.\nClient breaks file into chunks, sends them with different requests, then finalizes them with another request.\n\n## Install\n\nAdd it to your Gemfile then run `bundle` to install it.\n\n```ruby\ngem 'chunk_uploader', git: 'git@bitbucket.org:techery/chunk-uploader.git'\nbundle install\n```\n\n## Setup\n\nImagine, you have a model Video.\nTo be able to use this gem, you need to add `:file`, `:status`, `:last_chunk_id` attributes to your Video model.\nCreate a migration to add the required fields:\n\n```ruby\nchange_table :videos do |t|\n  t.integer :status,        default: 0\n  t.integer :last_chunk_id, default: 0\n  t.string  :file\nend\n```\nNext, run:\n\n```console\nrake db:migrate\n```\n\nInclude `ChunkUploader module` into Video model and set upload path:\n\n```ruby\ninclude ChunkUploader\nuploads_chunks_to \"#{Rails.root}/public/uploads\"\n```\n\nMount uploader you work with to `:file` attribute:\n\n```ruby\nmount_uploader :file, VideoUploader\n```\n\nThen configure your `config/routes.rb` file.\n\n```ruby\nresources :videos do\n  member do\n    put 'append_chunk', controller: 'videos', action: 'append_chunk'\n    put 'finalize',     controller: 'videos', action: 'finalize_upload'\n  end\nend\n```\n\n## Usage\n\nNow you can use it in the following flow.\n\n1. Create video object.\n\n    ```\n    POST /api/videos\n    ```\n\n    Get video `:id` from response\n\n2. Send chunks in different requests.\n\n    ```\n    PUT /api/videos/:id/append_chunk\n    ```\n\n    Process request in controller:\n\n    ```\n    video.append_chunk_to_file!(id: params[:chunk][:id], data: params[:chunk][:data])\n    ```\n\n3. Finalize uploading.\n\n    ```\n    PUT /api/videos/:id/finalize\n    ```\n\n    Process request in controller:\n\n    ```\n    video.finalize_upload_by!(checksum: params[:video][:checksum], filename: params[:video][:filename])\n    ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechery%2Fchunk-uploader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechery%2Fchunk-uploader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechery%2Fchunk-uploader/lists"}