class WarpEngine::Build::UploadsController
Receives build artifacts from CI into the file container. Needs a credential with the upload scope in X-Update-Secret (see WarpEngine::UpdateAuthentication).
Public Instance Methods
Source
# File app/controllers/warp_engine/build/uploads_controller.rb, line 39 def create unless update_authorized?(required_scope: WarpEngine::ApplicationToken::UPLOAD_SCOPE) return render json: { error: "Unauthorized" }, status: :unauthorized end input = WarpEngine::UploadInputDto.new( name: params[:name].to_s, version: params[:version].to_s, file: params[:file], sha256: params[:sha256] ) return render json: { error: input.error_message }, status: :bad_request unless input.valid? unless software_ownership_authorized?(input.name) return render json: { error: "Forbidden" }, status: :forbidden end max = WarpEngine.config.max_upload_size if input.file.size > max return render json: { error: "File too large (max #{max / (1024 * 1024)}MB)" }, status: :payload_too_large end digest = Digest::SHA256.file(input.file.tempfile.path).hexdigest if input.sha256.present? && !ActiveSupport::SecurityUtils.secure_compare(input.sha256.downcase, digest) return render json: { error: "SHA256 mismatch" }, status: :unprocessable_entity end stored = WarpEngine::FileManagerService.new.upload("", input.file) render json: { file: stored, size: input.file.size, sha256: digest } end
POST /build/upload (multipart).
- name
-
the software name
- version
-
the version string
- file
-
the artifact, its file name prefixed with
<name>-<version> - sha256
-
optional expected SHA-256 hex digest
Stores the file through WarpEngine::FileManagerService and renders { "file", "size", "sha256" }. Responds 401 without a valid credential, 400 for invalid input (WarpEngine::UploadInputDto), 403 when the token does not own the software, 413 above max_upload_size and 422 on a digest mismatch.