VR Package Upload API

VR Package Upload API

Upload APK files for VR learning experiences.

Endpoint

POST /api/vr-packages/upload

Overview

Uploads an APK file to storage and creates the package record in a single request. This endpoint handles multipart form data and supports files up to 2GB.

Authentication

Requires authentication. User must be an instructor, admin, or super_admin.

Request

Content-Type: multipart/form-data

FieldTypeRequiredDescription
fileFileYesAPK file (must have .apk extension)
titlestringNoPackage title (default: "Untitled VR Experience")
descriptionstringNoPackage description
versionstringNoPackage version (default: "1.0.0")
target_platformsstringNoJSON array or comma-separated list of platforms

Response (201 Created)

{
  "package": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "tenant_id": "tenant-uuid",
    "title": "Safety Training VR",
    "description": "Immersive workplace safety training",
    "version": "1.0.0",
    "storage_path": "tenant-id/vr/1699999999999_safety.apk",
    "storage_backend": "supabase",
    "file_size_bytes": 52428800,
    "target_platforms": ["quest2", "quest3"],
    "checksum": "sha256:abc123...",
    "status": "active",
    "created_at": "2025-01-15T10:00:00Z",
    "created_by": "user-uuid"
  },
  "message": "VR package uploaded successfully"
}

Error Responses

StatusCodeDescription
400MISSING_FILENo file provided
400INVALID_FILE_TYPEFile must be an APK
401UNAUTHORIZEDAuthentication required
403FORBIDDENOnly instructors and admins can upload
404PROFILE_NOT_FOUNDUser profile not found
413FILE_TOO_LARGEFile exceeds 2GB limit
500BUCKET_NOT_FOUNDStorage bucket not configured
500UPLOAD_FAILEDFailed to upload file
500DB_ERRORFailed to create package record

Configuration

  • Max File Size: 2GB
  • Max Duration: 5 minutes (for large uploads)
  • Storage Bucket: vr-packages
  • Allowed Extensions: .apk

Example Request

curl -X POST "https://api.allurelms.com/api/vr-packages/upload" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F "file=@safety-training.apk" \
  -F "title=Safety Training VR" \
  -F "description=Immersive workplace safety training" \
  -F "version=1.0.0" \
  -F 'target_platforms=["quest2", "quest3"]'

Security Notes

  • File checksum (SHA256) is computed server-side
  • Files are stored with sanitized filenames
  • Storage path includes tenant isolation
  • If database insert fails, uploaded file is automatically cleaned up

Related