@@ -56,33 +56,23 @@ function getresponseContentType (response: IN8nHttpFullResponse): string {
56
56
}
57
57
58
58
function getFileTypeFromContentType ( contentType : string ) : string {
59
+ // application/pdf -> pdf
60
+ // image/jpeg -> jpeg
59
61
const type = contentType . split ( ';' ) [ 0 ] . trim ( )
62
+
63
+ // any/thing -> any
64
+ if ( type . includes ( '/' ) ) {
65
+ return type . split ( '/' ) [ 0 ]
66
+ }
67
+
60
68
return type
61
69
}
62
70
63
71
function getFileExtensionFromContentType ( contentType : string ) : string {
64
72
const type = contentType . split ( ';' ) [ 0 ] . trim ( )
65
73
66
- // @ts -ignore
67
- console . log ( 'type' , contentType , type , type . split ( '/' ) [ 1 ] )
68
-
69
- if ( / ^ i m a g e \/ / . test ( type ) ) {
70
- return type . split ( '/' ) [ 1 ]
71
- }
72
-
73
- if ( / ^ a u d i o \/ / . test ( type ) ) {
74
- return type . split ( '/' ) [ 1 ]
75
- }
76
-
77
- if ( / ^ v i d e o \/ / . test ( type ) ) {
78
- return type . split ( '/' ) [ 1 ]
79
- }
80
-
81
- if ( / ^ t e x t \/ / . test ( type ) ) {
82
- return type . split ( '/' ) [ 1 ]
83
- }
84
-
85
- if ( / ^ a p p l i c a t i o n \/ / . test ( type ) ) {
74
+ // any/thing -> thing
75
+ if ( typeof type === 'string' && type . includes ( '/' ) ) {
86
76
return type . split ( '/' ) [ 1 ]
87
77
}
88
78
@@ -99,14 +89,11 @@ export const postReceiveActionBinaryData: PostReceiveAction =
99
89
100
90
const { binary } = items [ 0 ]
101
91
102
- if ( binary && binary . data ) {
92
+ if ( binary && binary . data && binary . data . mimeType === 'text/plain' ) {
103
93
const data = binary . data as IBinaryData
104
94
data . mimeType = contentType
105
95
data . fileType = getFileTypeFromContentType ( contentType ) as BinaryFileType
106
96
data . fileExtension = getFileExtensionFromContentType ( contentType )
107
-
108
- // @ts -ignore
109
- console . log ( 'data' , data )
110
97
}
111
98
112
99
return items
0 commit comments