Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
zango-strapi
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 3440fe10
authored
2024-05-31 16:40:33 +0530
by
jaymehta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
img upload
1 parent
014fb18d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
89 additions
and
10 deletions
package-lock.json
package.json
src/api/experience/controllers/experience.js
src/api/test/content-types/test/schema.json
src/api/test/controllers/test.js
src/components/images/images.json
src/components/img-component/img-component.json
yarn.lock
package-lock.json
View file @
3440fe1
This diff is collapsed.
Click to expand it.
package.json
View file @
3440fe1
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
"@strapi/provider-email-nodemailer"
:
"^4.3.8"
,
"@strapi/provider-email-nodemailer"
:
"^4.3.8"
,
"@strapi/provider-upload-aws-s3"
:
"^4.3.9"
,
"@strapi/provider-upload-aws-s3"
:
"^4.3.9"
,
"@strapi/strapi"
:
"4.3.6"
,
"@strapi/strapi"
:
"4.3.6"
,
"@strapi/utils"
:
"^4.24.3"
,
"better-sqlite3"
:
"7.4.6"
,
"better-sqlite3"
:
"7.4.6"
,
"csv-parse"
:
"^5.5.5"
,
"csv-parse"
:
"^5.5.5"
,
"mysql"
:
"^2.18.1"
,
"mysql"
:
"^2.18.1"
,
...
...
src/api/experience/controllers/experience.js
View file @
3440fe1
...
@@ -56,6 +56,17 @@ module.exports = createCoreController("api::experience.experience", () => ({
...
@@ -56,6 +56,17 @@ module.exports = createCoreController("api::experience.experience", () => ({
"Activity with the same name already exists, please rename the activity."
"Activity with the same name already exists, please rename the activity."
);
);
}
}
let
finalImageArray
=
[];
for
(
let
index
=
0
;
index
<
ctx
.
request
.
body
.
data
.
imagesComponent
.
length
;
index
++
)
{
const
element
=
ctx
.
request
.
body
.
data
.
imagesComponent
[
index
];
finalImageArray
=
[...
finalImageArray
,
{
image
:
element
}];
}
ctx
.
request
.
body
.
data
.
imagesComponent
;
// Create Activity
// Create Activity
const
activity
=
await
strapi
.
entityService
.
create
(
const
activity
=
await
strapi
.
entityService
.
create
(
"api::experience.experience"
,
"api::experience.experience"
,
...
@@ -92,7 +103,7 @@ module.exports = createCoreController("api::experience.experience", () => ({
...
@@ -92,7 +103,7 @@ module.exports = createCoreController("api::experience.experience", () => ({
contactPersonForBooking
:
contactPersonForBooking
:
ctx
.
request
.
body
.
data
.
contactPersonForBooking
,
ctx
.
request
.
body
.
data
.
contactPersonForBooking
,
approved
:
ctx
.
request
.
body
.
data
.
approved
,
approved
:
ctx
.
request
.
body
.
data
.
approved
,
imagesComponent
:
ctx
.
request
.
body
.
data
.
imagesArrayComponent
,
imagesComponent
:
finalImageArray
,
...
ctx
.
request
.
body
.
data
.
daysBoolean
,
...
ctx
.
request
.
body
.
data
.
daysBoolean
,
},
},
}
}
...
...
src/api/test/content-types/test/schema.json
View file @
3440fe1
...
@@ -4,7 +4,8 @@
...
@@ -4,7 +4,8 @@
"info"
:
{
"info"
:
{
"singularName"
:
"test"
,
"singularName"
:
"test"
,
"pluralName"
:
"tests"
,
"pluralName"
:
"tests"
,
"displayName"
:
"test"
"displayName"
:
"test"
,
"description"
:
""
},
},
"options"
:
{
"options"
:
{
"draftAndPublish"
:
true
"draftAndPublish"
:
true
...
@@ -15,14 +16,21 @@
...
@@ -15,14 +16,21 @@
"type"
:
"string"
"type"
:
"string"
},
},
"images"
:
{
"images"
:
{
"type"
:
"media"
,
"multiple"
:
true
,
"required"
:
false
,
"allowedTypes"
:
[
"allowedTypes"
:
[
"images"
,
"images"
,
"files"
,
"files"
,
"videos"
,
"videos"
,
"audios"
"audios"
],
]
"type"
:
"media"
,
},
"multiple"
:
true
"imgComponent"
:
{
"displayName"
:
"imgComponent"
,
"type"
:
"component"
,
"repeatable"
:
true
,
"component"
:
"img-component.img-component"
}
}
}
}
}
}
src/api/test/controllers/test.js
View file @
3440fe1
'use strict'
;
"use strict"
;
/**
/**
* test controller
* test controller
*/
*/
const
{
createCoreController
}
=
require
(
'@strapi/strapi'
).
factories
;
const
{
createCoreController
}
=
require
(
"@strapi/strapi"
).
factories
;
const
{
parseMultipartData
,
sanitizeEntity
}
=
require
(
"@strapi/utils"
);
module
.
exports
=
createCoreController
(
'api::test.test'
);
module
.
exports
=
createCoreController
(
"api::test.test"
,
()
=>
({
async
create
(
ctx
)
{
let
entity
;
if
(
ctx
.
request
.
is
(
"multipart/form-data"
))
{
const
{
body
:
data
,
files
}
=
ctx
.
request
;
console
.
log
(
"Data:"
,
data
);
console
.
log
(
"Files:"
,
files
);
// Ensure imgComponent structure
if
(
data
.
imgComponent
&&
Array
.
isArray
(
data
.
imgComponent
))
{
data
.
imgComponent
=
data
.
imgComponent
.
map
((
item
,
index
)
=>
({
...
item
,
image
:
files
[
`imgComponent[
${
index
}
].image`
],
// Ensure correct structure
}));
}
console
.
log
(
"final"
,
data
.
data
,
files
);
try
{
entity
=
await
strapi
.
entityService
.
create
(
"api::test.test"
,
{
data
,
files
,
});
console
.
log
(
"entity, "
,
entity
);
return
ctx
.
send
({
payload
:
entity
,
success
:
true
});
}
catch
(
error
)
{
console
.
error
(
error
);
ctx
.
throw
(
500
,
error
.
message
);
}
}
else
{
ctx
.
throw
(
400
,
"Request must be multipart/form-data"
);
}
},
}));
src/components/images/images.json
View file @
3440fe1
...
@@ -7,8 +7,15 @@
...
@@ -7,8 +7,15 @@
},
},
"options"
:
{},
"options"
:
{},
"attributes"
:
{
"attributes"
:
{
"imageUrl"
:
{
"image"
:
{
"type"
:
"string"
"allowedTypes"
:
[
"images"
,
"files"
,
"videos"
,
"audios"
],
"type"
:
"media"
,
"multiple"
:
false
}
}
}
}
}
}
src/components/img-component/img-component.json
0 → 100644
View file @
3440fe1
{
"collectionName"
:
"components_img_component_img_components"
,
"info"
:
{
"displayName"
:
"imgComponent"
},
"options"
:
{},
"attributes"
:
{
"image"
:
{
"allowedTypes"
:
[
"images"
,
"files"
,
"videos"
,
"audios"
],
"type"
:
"media"
,
"multiple"
:
false
}
}
}
yarn.lock
View file @
3440fe1
This diff could not be displayed because it is too large.
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment