This file contains hidden or 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
function hasAnnotations (text) { | |
return getNextAnnotationStartIndex(text) !== -1 || | |
getNextAnnotationEndIndex(text) !== -1; | |
} | |
function getNextAnnotationStartIndex (text) { | |
return text.indexOf(`\n\n**`) | |
} | |
function getNextAnnotationEndIndex (text) { |
This file contains hidden or 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
import React from "react"; | |
import { useMutation, gql } from "@apollo/client"; | |
const SINGLE_UPLOAD = gql` | |
mutation($file: Upload!) { | |
singleUpload(file: $file) { | |
filename | |
mimetype | |
encoding | |
url |
This file contains hidden or 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
import { useMutation, gql } from "@apollo/client"; | |
const SINGLE_UPLOAD = gql` | |
mutation($file: Upload!) { | |
singleUpload(file: $file) { | |
filename | |
mimetype | |
encoding | |
url | |
} |
This file contains hidden or 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
const UploadFile = () => { | |
const [mutate, { loading, error }] = useMutation(SINGLE_UPLOAD); | |
const onChange = ({ | |
target: { | |
validity, | |
files: [file] | |
} | |
}: any) => validity.valid && mutate({ variables: { file } }); | |
if (loading) return <div>Loading...</div>; |
This file contains hidden or 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
import React from "react"; | |
const App: React.FC = () => { | |
return ( | |
<UploadFile /> | |
); | |
}; | |
export default App; |
This file contains hidden or 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
import React from "react"; | |
import ReactDOM from "react-dom"; | |
import App from "./App"; | |
import "./index.css" | |
import { | |
ApolloClient, | |
InMemoryCache, | |
ApolloProvider, | |
HttpLink |
This file contains hidden or 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
import React from "react"; | |
import ReactDOM from "react-dom"; | |
import App from "./App"; | |
import "./index.css" | |
import { | |
ApolloClient, | |
InMemoryCache, | |
ApolloProvider, | |
HttpLink |
This file contains hidden or 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
async singleFileUploadResolver( | |
parent, | |
{ file }: { file: Promise<File> } | |
): Promise<ApolloServerFileUploads.UploadedFileResponse> { | |
const { stream, filename, mimetype, encoding } = await file; | |
// Create the destination file path | |
const filePath = this.createDestinationFilePath( | |
filename, | |
mimetype, |
This file contains hidden or 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
async singleFileUploadResolver( | |
parent, | |
{ file }: { file: Promise<ApolloServerFileUploads.File> } | |
): Promise<ApolloServerFileUploads.UploadedFileResponse> { | |
const { stream, filename, mimetype, encoding } = await file; | |
// Create the destination file path | |
const filePath = this.createDestinationFilePath( | |
filename, | |
mimetype, |
This file contains hidden or 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
import stream from "stream"; | |
type S3UploadStream = { | |
writeStream: stream.PassThrough; | |
promise: Promise<AWS.S3.ManagedUpload.SendData>; | |
}; | |
export class AWSS3Uploader implements ApolloServerFileUploads.IUploader { | |
private s3: AWS.S3; | |
public config: S3UploadConfig; |
NewerOlder