Skip to content

Commit

Permalink
Support non-PDF files in Paperless-NG
Browse files Browse the repository at this point in the history
Related: #18
  • Loading branch information
bauerj committed Dec 9, 2020
1 parent a5c1456 commit 326440a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class Document {
String checksum;
DateTime created;
DateTime modified;
String fileName;
String originalFileName;
String archivedFileName;

factory Document.fromJson(Map<String, dynamic> json) =>
_$DocumentFromJson(json);
Expand Down Expand Up @@ -72,6 +73,9 @@ class OgDocument extends Document {
@JsonKey(fromJson: _idsFromUrls)
List<int> tags;

@JsonKey(name: "file_name")
String originalFileName;

factory OgDocument.fromJson(Map<String, dynamic> json) =>
_$OgDocumentFromJson(json);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/online_pdf_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class _OnlinePdfDialogState extends State<OnlinePdfDialog> {
}

static Future<String> getDownloadPath(Document doc) async {
String fileName = doc.fileName ?? "x.pdf";
String fileName = doc.archivedFileName ?? doc.originalFileName ?? "x.pdf";
final fileType = fileName.split(".").last;
final tempDir = await getTemporaryDirectory();
return '${tempDir.path}/${doc.id}.$fileType';
Expand Down

0 comments on commit 326440a

Please sign in to comment.