Skip to content
This repository has been archived by the owner on Feb 27, 2022. It is now read-only.

Commit

Permalink
Fix: File upload property ‘stream’ is deprecated. Use ‘createReadStre…
Browse files Browse the repository at this point in the history
  • Loading branch information
sawakisei committed Dec 20, 2018
1 parent 35457e6 commit 1ba3118
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions server/database/model/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class Image extends Model {

if (!isThrow(() => isPromiseValid(input.file))) {
/** @type {import('../../graphql/interface/interface').FileUpload} */
const { stream, filename } = await input.file;
input.file = stream;
const { createReadStream, filename } = await input.file;
input.file = createReadStream();
imageData.name = filename;
}
const imageFromImgur = await uploadImage(input.file);
Expand Down
18 changes: 16 additions & 2 deletions server/graphql/interface/interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Stream } from 'stream';
import { ReadStream, PathLike } from 'fs';

/**
* @see {@link https://github.com/jaydenseric/graphql-upload/blob/master/src/GraphQLUpload.mjs}
Expand All @@ -19,5 +19,19 @@ export interface FileUpload {
/**
* Returns a Node.js readable stream of the file contents, for processing and storing the file. Multiple calls create independent streams. Throws if called after all resolvers have resolved, or after an error has interrupted the request.
*/
stream: Stream;
createReadStream: (
path: PathLike,
options?:
| string
| {
flags?: string;
encoding?: string;
fd?: number;
mode?: number;
autoClose?: boolean;
start?: number;
end?: number;
highWaterMark?: number;
},
) => ReadStream;
}

0 comments on commit 1ba3118

Please sign in to comment.