Skip to content

Commit 8d1d882

Browse files
Merge pull request #480 from CedricProfessionnel/SetUrlForTimeTextData
Add logic to create sample from time/text data (Feature Aws Part)
2 parents d7522ab + a42c841 commit 8d1d882

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/components/ImportFromCognitoS3Dialog/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export default ({ open, onClose, onAddSamples }) => {
178178

179179
const createJsonFromUrlAWS = async (projectName, imageName) => {
180180
var url = await dm.getAssetUrl(imageName, projectName)
181-
var json = setUrl(url, configImport)
181+
var json = await setUrl(url, configImport, dm)
182182
if (json) json = setIn(json, ["_id"], imageName)
183183
if (json) json = setIn(json, ["source"], projectName)
184184
return json

src/components/ImportFromCognitoS3Dialog/set-url.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import RecognizeFileExtension from "../../utils/get-data-url-type"
2-
const setUrl = (result, configImport) => {
3-
if (configImport.loadProjectIsSelected) {
2+
const setUrl = async (result, configImport, dm) => {
3+
var text
4+
var json
5+
if (!configImport.loadAssetIsSelected) {
46
if (RecognizeFileExtension(result) === "Image") {
57
return { imageUrl: `${result}` }
68
} else if (RecognizeFileExtension(result) === "Video") {
@@ -10,8 +12,11 @@ const setUrl = (result, configImport) => {
1012
} else if (RecognizeFileExtension(result) === "PDF") {
1113
return { pdfUrl: `${result}` }
1214
} else if (RecognizeFileExtension(result) === "Text") {
13-
//var text = await fetchTextInFile(result)
14-
return { document: `Is not supported` /*${text}`*/ }
15+
text = await dm.getAssetText({ txtUrl: `${result}` })
16+
return { document: `${text}` }
17+
} else if (configImport.typeOfFileToLoad === "Time") {
18+
json = await dm.getAssetTime({ timeUrl: `${result}` })
19+
return json
1520
}
1621
} else {
1722
if (
@@ -38,8 +43,14 @@ const setUrl = (result, configImport) => {
3843
RecognizeFileExtension(result) === configImport.typeOfFileToLoad &&
3944
configImport.typeOfFileToLoad === "Text"
4045
) {
41-
//var text = await fetchTextInFile(result)
42-
return { document: `Is not supported` /*${text}`*/ }
46+
text = await dm.getAssetText({ txtUrl: `${result}` })
47+
return { document: `${text}` }
48+
} else if (
49+
RecognizeFileExtension(result) === configImport.typeOfFileToLoad &&
50+
configImport.typeOfFileToLoad === "Time"
51+
) {
52+
json = await dm.getJSON(result)
53+
return json
4354
}
4455
}
4556
}

0 commit comments

Comments
 (0)