You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/toolwindow/AmazonQPanel.kt
+30-35Lines changed: 30 additions & 35 deletions
Original file line number
Diff line number
Diff line change
@@ -151,42 +151,12 @@ class AmazonQPanel(val project: Project, private val scope: CoroutineScope) : Di
151
151
val maxDimension =8000
152
152
153
153
for (file in fileList asList<File>) {
154
-
val fileName = file.name
155
-
val ext = fileName.substringAfterLast('.', "").lowercase()
156
-
157
-
// File type restriction
158
-
if (ext !in allowedTypes) {
159
-
errorMessages.add("$fileName: File must be an image in JPEG, PNG, GIF, or WebP format.")
160
-
continue
161
-
}
162
-
163
-
// Size restriction
164
-
if (file.length() > maxFileSize) {
165
-
errorMessages.add("$fileName: Image must be no more than 3.75MB in size.")
166
-
continue
167
-
}
168
-
169
-
// Width/Height restriction (only for image types)
170
-
try {
171
-
val img = read(file)
172
-
if (img ==null) {
173
-
errorMessages.add("$fileName: File could not be read as an image.")
174
-
continue
175
-
}
176
-
if (img.width > maxDimension) {
177
-
errorMessages.add("$fileName: Image must be no more than 8,000px in width.")
178
-
continue
179
-
}
180
-
if (img.height > maxDimension) {
181
-
errorMessages.add("$fileName: Image must be no more than 8,000px in height.")
182
-
continue
183
-
}
184
-
} catch (e:Exception) {
185
-
errorMessages.add("$fileName: File could not be read as an image.")
186
-
continue
154
+
val validationResult = validateImageFile(file, allowedTypes, maxFileSize, maxDimension)
155
+
if (validationResult !=null) {
156
+
errorMessages.add(validationResult)
157
+
} else {
158
+
validImages.add(file)
187
159
}
188
-
189
-
validImages.add(file)
190
160
}
191
161
192
162
// File count restriction
@@ -312,6 +282,31 @@ class AmazonQPanel(val project: Project, private val scope: CoroutineScope) : Di
0 commit comments