18 lines
469 B
JavaScript
18 lines
469 B
JavaScript
'use client';
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
export function CurlUploadExample({ path, token = '', fileName = 'datei.pdf' }) {
|
|
const [url, setUrl] = useState(path);
|
|
|
|
useEffect(() => {
|
|
setUrl(new URL(path, window.location.origin).toString());
|
|
}, [path]);
|
|
|
|
const header = token
|
|
? `-H 'Authorization: Bearer ${token}'`
|
|
: `-H 'X-File-Name: ${fileName}'`;
|
|
|
|
return <pre><code>{`curl -T ./${fileName} ${header} '${url}'`}</code></pre>;
|
|
}
|