Repository navigation
feat(client): list, download, upload and delete record attachments - #57
Merged
Merged
Conversation
Client gains getAttachments(), getAttachmentContent(), addAttachment()
and deleteAttachment() for the attachments of a record of the configured
evidence. The calls follow the FlexiBee attachment API and were checked
against the public demo server: the list is read from the "priloha"
collection, content is returned as raw bytes, an upload is a PUT of the
raw content to prilohy/new/{name} with its Content-Type (the new id comes
from results[0].id), and a delete is a DELETE of the attachment detail.
To send a raw body, CurlRequest gets an optional body, HttpClient gets
send(CurlRequest, Config) (request() delegates to it) and
HttpCurlBuilder::build() takes the CurlRequest.
Closes #31
CR finding (Moderate): ResponseFactory returned FlexibeePdfResponse for any URL containing ".pdf", for any method. Uploading an attachment named faktura.pdf (PUT .../prilohy/new/faktura.pdf) therefore lost the JSON result with the new attachment id, and a search filter mentioning ".pdf" was not parsed. A response is now binary PDF only for a GET whose URL path ends with ".pdf".
pekral
marked this pull request as ready for review
November 12, 2026 15:10
Collaborator
Author
CR status — convergedStatus: converged after 2 review iterations · Critical 0 · Moderate 0 Resolved items
|
Collaborator
Author
Code ReviewStatus: clean Summary: 0 Critical · 0 Moderate · 0 Minor · 0 Refactoring · assignment conformance: conformant (#31: attachments API — list, download, upload, delete — implemented and verified against the demo server) · reviewer comments: none |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #31
TL;DR
Podpora příloh záznamů evidence: seznam, stažení, nahrání a smazání. Všechny čtyři operace jsem ověřil na veřejném demo serveru FlexiBee.
Změny
Client::getAttachments(int $id)vrací poleEvidenceResultz kolekcepriloha(id,nazSoub,contentType, …).Client::getAttachmentContent(int $id, int $attachmentId)vrací binární obsah přílohy. Pro neexistující přílohu vyhodíEcomailFlexibeeNoEvidenceResult.Client::addAttachment(int $id, string $fileName, string $content, string $contentType)nahraje přílohu a vrátí ID nové přílohy. Název souboru se v URL kóduje.Client::deleteAttachment(int $id, int $attachmentId)smaže přílohu.CurlRequestmá volitelnébodypro binární obsah,HttpClient::send(CurlRequest, Config), na kterou deleguje stávajícírequest(),ResponseFactoryvracíFlexibeeAttachmentResponseproGET …/contentse statusem 200, podobně jako u PDF.ResponseFactoryčetla jako PDF každou odpověď, jejíž URL kdekoli obsahovala.pdf, u jakékoli metody. Nahrání přílohyfaktura.pdfby tak ztratilo ID nové přílohy. Teď se PDF pozná jen uGET, jehož cesta končí na.pdf. Chyba byla už ve verzi 1.4 (u filtrů s.pdf).Ověření proti demo serveru
Testovací příloha byla po každém zápisu hned smazána a demo zůstalo v původním stavu.
GET /c/demo/cenik/code:DRÁT/prilohy.json{"winstrom":{"priloha":[{"id":"14","nazSoub":…,"contentType":…}]}}GET …/prilohy/15/content200,image/jpeg, binární dataPUT …/prilohy/new/flexibee-client-test.txtsContent-Type: text/plainaAccept: application/json201,results[0].id+LocationDELETE …/prilohy/{id}.json200, příloha zmizela ze seznamuSmazání přílohy dokumentace výslovně neuvádí. Vychází z obecného pravidla „mazat lze jednotlivé záznamy přes jejich detailové URL“ a na demo serveru funguje.
Zdroje
Merge danger
HttpCurlBuilder::build()(interní třída) přijímáCurlRequest, uvedeno v UPGRADE-2.0.md.Testování
HttpClient::send, metody klienta).composer checkprochází, pokrytí změněných řádků 58/58.addAttachment()u záznamu,getAttachments()ho musí obsahovat,getAttachmentContent()vrátí stejný obsah,deleteAttachment()ho odstraní.