File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
src/plone/restapi/serializer Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 23
23
from zope .schema .interfaces import IVocabularyTokenized
24
24
25
25
import logging
26
+ import os
26
27
27
28
28
29
log = logging .getLogger (__name__ )
@@ -203,6 +204,19 @@ def __call__(self):
203
204
if namedfile is None :
204
205
return
205
206
207
+ enable_transform = os .environ .get ("enable_link_target_transform" , False )
208
+
209
+ if enable_transform :
210
+ download_url = "/" .join ((self .context .absolute_url (), "@@download" , self .field .__name__ ))
211
+ result = {
212
+ "url" : self .context .absolute_url (),
213
+ "download" : download_url ,
214
+ "filename" : namedfile .filename ,
215
+ "content-type" : namedfile .contentType ,
216
+ "size" : namedfile .getSize (),
217
+ }
218
+ return json_compatible (result )
219
+
206
220
return "/" .join (
207
221
(self .context .absolute_url (), "@@download" , self .field .__name__ )
208
222
)
You can’t perform that action at this time.
0 commit comments