Skip to content

Commit e08bbb2

Browse files
authored
Merge pull request #744 from baudev/baudev-file-upload
Fix bugs in Managing Files and Images code
2 parents 0a6b8ed + a4716c7 commit e08bbb2

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

admin/getting-started.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,8 @@ const myApiDocumentationParser = entrypoint => parseHydraDocumentation(entrypoin
149149
src: value
150150
});
151151
152-
field.field = (
153-
<FunctionField
154-
key={field.name}
155-
render={
156-
record => (
157-
<ImageField key={field.name} record={record} source={`${field.name}.src`}/>
158-
)
159-
}
160-
source={field.name}
161-
/>
152+
field.field = props => (
153+
<ImageField {...props} source={`${field.name}.src`} />
162154
);
163155

164156
field.input = (
@@ -168,9 +160,9 @@ const myApiDocumentationParser = entrypoint => parseHydraDocumentation(entrypoin
168160
);
169161

170162
field.normalizeData = value => {
171-
if (value[0] && value[0].rawFile instanceof File) {
163+
if (value && value.rawFile instanceof File) {
172164
const body = new FormData();
173-
body.append('file', value[0].rawFile);
165+
body.append('file', value.rawFile);
174166

175167
return fetch(`${entrypoint}/images/upload`, { body, method: 'POST' })
176168
.then(response => response.json());

0 commit comments

Comments
 (0)