Conversation
Add support for uploading documents and checking memo processing status, matching features from skald-python commit a7fbaf6. New features: - createMemoFromFile(): Upload documents (PDF, DOC, DOCX, PPTX) up to 100MB - checkMemoStatus(): Check memo processing status (processing, processed, error) - MemoFileData type for file upload metadata - MemoStatusResponse type with convenience methods (isProcessing, isProcessed, isError) Testing: - Added comprehensive unit tests for both features - Added example scripts: upload_file.php and check_memo_status.php - Updated README with full documentation and examples 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Pull Request Review: File Upload and Memo Status CheckingSummaryThis PR adds file upload support and memo status checking functionality to the Skald PHP SDK. The implementation is well-structured and follows the existing codebase patterns. Overall, this is high-quality code that maintains consistency with the rest of the SDK. StrengthsCode Quality
Implementation
Testing
Documentation
Issues and Recommendations1. Security: Filename Sanitization (Medium Priority)Location: src/Skald.php:123 The filename is not sanitized before inclusion in multipart form data. Filenames with quotes or special characters could break the format or lead to header injection. Recommendation: Sanitize filename by removing quotes and newlines before use. 2. Performance: Memory Usage for Large Files (Medium Priority)Location: src/Skald.php:124 The entire file is loaded into memory with file_get_contents(). For files near 100MB, this causes memory issues on servers with lower limits. Recommendation: Use CURLFile object for memory-efficient streaming uploads instead of loading entire file. 3. Bug: JSON Encoding Error Handling (Low Priority)Location: src/Skald.php:139 json_encode() can return false on error, but this is not checked. Recommendation: Add error handling for JSON encoding failures. 4. Missing Test Coverage (Low Priority)Tests needed for: file size exceeding 100MB, unreadable files, filesize() failure, JSON encoding failure in metadata. 5. Code Style: MemoFileData Inconsistency (Minor)MemoData.toArray() defaults metadata to empty array, but MemoFileData.toArray() excludes it if null. Document why behavior differs. 6. Documentation: API Response FlowShow complete flow from upload to status checking including how to get memo_uuid from upload response. Security AssessmentPassed: Input validation, authentication, error handling, type safety Needs attention: Filename sanitization, consider MIME type validation Performance Considerations
Overall AssessmentRecommendation: APPROVE with minor changes
Priority:
Great work! The code quality is excellent and this will be a valuable addition to the SDK. |
Summary
createMemoFromFile()method for uploading documents (PDF, DOC, DOCX, PPTX up to 100MB)checkMemoStatus()method to monitor memo processing statusChanges
New Methods
createMemoFromFile(string $filePath, ?MemoFileData $memoData): Upload document files with optional metadatacheckMemoStatus(string $memoId, string $idType): Check processing status of memosNew Types
MemoFileData: Data structure for file upload metadataMemoStatusResponse: Response type with status and convenience methods (isProcessing(),isProcessed(),isError())Examples
examples/upload_file.php: Demonstrates file upload with metadataexamples/check_memo_status.php: Shows status checking and polling patternsTests
Documentation
Test plan
🤖 Generated with Claude Code