-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(front): add file upload and fetch (#72)
* chore(kube): remove ingress class name on ingress * feat(api): increase codec max in-memory size * feat(front): add profile picture upload * feat(front): add profile picture fetch * feat(front): add resume upload * feat(front): add resume fetch * chore: run linter
- Loading branch information
Showing
18 changed files
with
321 additions
and
16 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
backend/api_gateway/src/main/kotlin/com/linkedout/backend/config/WebFluxConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.linkedout.backend.config | ||
|
||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.http.codec.ServerCodecConfigurer | ||
import org.springframework.web.reactive.config.WebFluxConfigurer | ||
|
||
@Configuration | ||
internal open class WebFluxConfiguration : WebFluxConfigurer { | ||
override fun configureHttpMessageCodecs(configurer: ServerCodecConfigurer) { | ||
configurer.defaultCodecs().maxInMemorySize(8 * 1024 * 1024) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
spring: | ||
codec: | ||
max-in-memory-size: 8MB | ||
security: | ||
oauth2: | ||
resourceserver: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import * as FileSystem from 'expo-file-system'; | ||
import * as Sharing from 'expo-sharing'; | ||
import { useCallback } from 'react'; | ||
import { Alert } from 'react-native'; | ||
import { Button } from 'react-native-paper'; | ||
|
||
import { useAppSelector } from '@/store/hooks'; | ||
import i18n from '@/utils/i18n'; | ||
|
||
/** | ||
* Button to share the resume of the user. | ||
* @constructor | ||
*/ | ||
export const ProfileShareResumeButton = () => { | ||
// Store hooks | ||
const auth = useAppSelector((state) => state.auth); | ||
|
||
// Callbacks | ||
const handleDownloadResume = useCallback(async () => { | ||
if (auth.state !== 'authenticated') { | ||
return; | ||
} | ||
|
||
const downloadResult = await FileSystem.downloadAsync( | ||
`${process.env.EXPO_PUBLIC_API_URL}/profile/cv`, | ||
FileSystem.cacheDirectory + 'cv.pdf', | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${auth.token}`, | ||
}, | ||
}, | ||
); | ||
|
||
if (downloadResult.status !== 200) { | ||
if (downloadResult.status === 404) { | ||
Alert.alert( | ||
i18n.t('profile.info.resumeNotFound.title'), | ||
i18n.t('profile.info.resumeNotFound.message'), | ||
); | ||
} else { | ||
Alert.alert( | ||
i18n.t('profile.info.resumeDownloadError.title'), | ||
i18n.t('profile.info.resumeDownloadError.message'), | ||
); | ||
} | ||
|
||
return; | ||
} | ||
|
||
await Sharing.shareAsync(downloadResult.uri); | ||
}, [auth]); | ||
|
||
return ( | ||
<Button | ||
mode='contained-tonal' | ||
onPress={handleDownloadResume} | ||
icon='file-document-outline' | ||
> | ||
{i18n.t('profile.info.shareResume')} | ||
</Button> | ||
); | ||
}; | ||
|
||
export default ProfileShareResumeButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
front/src/components/profile/ProfileUploadPictureButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as ImagePicker from 'expo-image-picker'; | ||
import { useCallback } from 'react'; | ||
import { Button } from 'react-native-paper'; | ||
|
||
import { useUploadProfilePictureMutation } from '@/store/api/profileApiSlice'; | ||
import i18n from '@/utils/i18n'; | ||
|
||
/** | ||
* Button to upload the profile picture of the user. | ||
* @constructor | ||
*/ | ||
export const ProfileUploadPictureButton = () => { | ||
// API calls | ||
const [uploadProfilePicture] = useUploadProfilePictureMutation(); | ||
|
||
// Callbacks | ||
const handleUploadPicture = useCallback(async () => { | ||
const result = await ImagePicker.launchImageLibraryAsync({ | ||
allowsEditing: true, | ||
aspect: [1, 1], | ||
exif: false, | ||
quality: 0.4, | ||
}); | ||
|
||
if (result.canceled === true || result.assets.length === 0) { | ||
return; | ||
} | ||
|
||
uploadProfilePicture(result.assets[0].uri); | ||
}, [uploadProfilePicture]); | ||
|
||
return ( | ||
<Button | ||
mode='contained-tonal' | ||
onPress={handleUploadPicture} | ||
icon='image-plus' | ||
> | ||
{i18n.t('profile.info.uploadPicture')} | ||
</Button> | ||
); | ||
}; | ||
|
||
export default ProfileUploadPictureButton; |
40 changes: 40 additions & 0 deletions
40
front/src/components/profile/ProfileUploadResumeButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import * as DocumentPicker from 'expo-document-picker'; | ||
import { useCallback } from 'react'; | ||
import { Button } from 'react-native-paper'; | ||
|
||
import { useUploadResumeMutation } from '@/store/api/profileApiSlice'; | ||
import i18n from '@/utils/i18n'; | ||
|
||
/** | ||
* Button to upload the resume of the user. | ||
* @constructor | ||
*/ | ||
export const ProfileUploadResumeButton = () => { | ||
// API calls | ||
const [uploadResume] = useUploadResumeMutation(); | ||
|
||
// Callbacks | ||
const handleUploadResume = useCallback(async () => { | ||
const result = await DocumentPicker.getDocumentAsync({ | ||
type: 'application/pdf', | ||
}); | ||
|
||
if (result.canceled === true || result.assets.length === 0) { | ||
return; | ||
} | ||
|
||
uploadResume(result.assets[0].uri); | ||
}, [uploadResume]); | ||
|
||
return ( | ||
<Button | ||
mode='contained-tonal' | ||
onPress={handleUploadResume} | ||
icon='file-upload-outline' | ||
> | ||
{i18n.t('profile.info.uploadResume')} | ||
</Button> | ||
); | ||
}; | ||
|
||
export default ProfileUploadResumeButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
interface FormDataValue { | ||
uri: string; | ||
name: string; | ||
type: string; | ||
} | ||
|
||
interface FormData { | ||
append(name: string, value: FormDataValue, fileName?: string): void; | ||
set(name: string, value: FormDataValue, fileName?: string): void; | ||
} |
Oops, something went wrong.