@@ -18,6 +18,8 @@ export interface IpfsUploadResponse {
1818 cid : string ;
1919 /** Gateway URLs where the content can be accessed */
2020 gatewayUrls : string [ ] ;
21+ /** SHA-256 hex (64 chars) of uploaded bytes (after EXIF strip); for `file_claim` evidence. */
22+ contentSha256Hex : string ;
2123 /** Original filename (sanitized) */
2224 filename ?: string ;
2325 /** File size in bytes */
@@ -140,12 +142,17 @@ export class IpfsService {
140142
141143 if ( ! idempotencyCheck . shouldUpload && idempotencyCheck . existingRecord ) {
142144 this . logger . log ( `Returning cached response for idempotent request: ${ idempotencyCheck . key } ` ) ;
145+ const cached = idempotencyCheck . existingRecord . response ;
143146 return {
144- ...idempotencyCheck . existingRecord . response ,
147+ cid : cached . cid ,
148+ gatewayUrls : cached . gatewayUrls ,
149+ contentSha256Hex :
150+ cached . contentSha256Hex ?? idempotencyCheck . contentHash ,
145151 filename : sanitizedFilename ,
146152 size : processedBuffer . length ,
147153 mimeType,
148154 duplicated : true ,
155+ uploadedAt : cached . uploadedAt ,
149156 } ;
150157 }
151158
@@ -160,9 +167,12 @@ export class IpfsService {
160167 throw new ServiceUnavailableException ( 'IPFS provider is temporarily unavailable' ) ;
161168 }
162169
170+ const contentSha256Hex =
171+ this . fileValidationService . calculateContentHash ( processedBuffer ) ;
172+
163173 // Upload to IPFS
164174 this . logger . debug ( `Uploading ${ sanitizedFilename } (${ processedBuffer . length } bytes) to IPFS` ) ;
165-
175+
166176 let uploadResult : IpfsUploadResult ;
167177 try {
168178 uploadResult = await this . provider . upload (
@@ -183,7 +193,7 @@ export class IpfsService {
183193 await this . idempotencyService . storeResult (
184194 idempotencyCheck . key ,
185195 contentHash ,
186- { cid : uploadResult . cid , gatewayUrls } ,
196+ { cid : uploadResult . cid , gatewayUrls, contentSha256Hex } ,
187197 ) ;
188198
189199 const duration = Date . now ( ) - startTime ;
@@ -194,6 +204,7 @@ export class IpfsService {
194204 return {
195205 cid : uploadResult . cid ,
196206 gatewayUrls,
207+ contentSha256Hex,
197208 filename : sanitizedFilename ,
198209 size : uploadResult . size ,
199210 mimeType : uploadResult . mimeType ,
0 commit comments