Skip to content

Commit

Permalink
👽 Tester ut nye endepunkter for les og slett av filer
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbjoern committed Dec 6, 2023
1 parent ae2969a commit da0b13e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/fileupload/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const FileUpload = ({ søknadId, krav, addError, deleteError, onSuccess,
const newFiles = files.filter((file) => file.vedleggId !== vedlegg.vedleggId);
setFiles(newFiles);
}}
deleteUrl={'/aap/mine-aap/api/vedlegg/slett/?uuid='}
deleteUrl={'/aap/mine-aap/api/innsending/vedlegg/slett/?uuid='}
uploadUrl={'/aap/mine-aap/api/innsending/vedlegg/lagre/'}
files={files}
/>
Expand Down
26 changes: 26 additions & 0 deletions pages/api/innsending/vedlegg/les.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { getStringFromPossiblyArrayQuery } from '@navikt/aap-felles-utils-client';
import { beskyttetApi, getAccessTokenFromRequest, tokenXApiProxy } from '@navikt/aap-felles-utils';

const handler = beskyttetApi(async (req, res) => {
const uuid = getStringFromPossiblyArrayQuery(req.query.uuid);
if (!uuid) {
res.status(400).json({ error: 'uuid må være en string' });
}
const accessToken = getAccessTokenFromRequest(req);
return await tokenXApiProxy({
url: `/mellomlagring/fil/${uuid}`,
method: 'GET',
prometheusPath: '/mellomlagring/fil',
req: req,
audience: process.env.INNSENDING_URL!,
bearerToken: accessToken,
});
});

export const config = {
api: {
responseLimit: '50mb',
},
};

export default handler;
20 changes: 20 additions & 0 deletions pages/api/innsending/vedlegg/slett.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { getStringFromPossiblyArrayQuery } from '@navikt/aap-felles-utils-client';
import { beskyttetApi, getAccessTokenFromRequest, tokenXApiProxy } from '@navikt/aap-felles-utils';

const handler = beskyttetApi(async (req, res) => {
const uuid = getStringFromPossiblyArrayQuery(req.query.uuid);
if (!uuid) {
res.status(400).json({ error: 'uuid må være en string' });
}
const accessToken = getAccessTokenFromRequest(req);
return await tokenXApiProxy({
url: `/mellomlagring/fil/${uuid}`,
method: 'DELETE',
prometheusPath: '/mellomlagring/fil',
req,
audience: process.env.INNSENDING_URL!,
bearerToken: accessToken,
});
});

export default handler;
2 changes: 1 addition & 1 deletion pages/vedlegg/[uuid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Vedlegg = ({ uuid }: PageProps) => {

useEffect(() => {
const getFile = async () => {
const file = await fetch(`/aap/mine-aap/api/vedlegg/les/?uuid=${uuid}`).then((res) => res.blob());
const file = await fetch(`/aap/mine-aap/api/innsending/vedlegg/les/?uuid=${uuid}`).then((res) => res.blob());
file && setFile(file);
};
getFile();
Expand Down

0 comments on commit da0b13e

Please sign in to comment.