Skip to content

Commit bcc107b

Browse files
ANKUR DWIVEDIANKUR DWIVEDI
authored andcommitted
added checks parameter
1 parent 316b1ae commit bcc107b

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,8 @@ imagekitio.upload_file(
452452
value: 'w-100'
453453
}
454454
]
455-
}
455+
},
456+
checks: "'request.folder' : '/'" # To run server side checks before uploading files. Notice the quotes around file.size and 1mb.
456457
)
457458

458459
```

lib/imagekitio/constants/file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module File
55

66
VALID_FILE_DETAIL_OPTIONS = ["fileID"]
77

8-
VALID_UPLOAD_OPTIONS = %w[file file_name use_unique_file_name tags folder is_private_file custom_coordinates response_fields extensions webhook_url overwrite_file overwrite_AI_tags overwrite_custom_metadata custom_metadata mime overwrite_tags content_type transformation ]
8+
VALID_UPLOAD_OPTIONS = %w[file file_name use_unique_file_name tags folder is_private_file custom_coordinates response_fields extensions webhook_url overwrite_file overwrite_AI_tags overwrite_custom_metadata custom_metadata mime overwrite_tags content_type transformation checks]
99
end
1010
end
1111
end

lib/imagekitio/sdk/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module ImageKitIo
22
module Sdk
3-
VERSION = '3.0.0'
3+
VERSION = '3.1.0'
44
end
55
end

test/imagekit/api_service/file_test.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,31 @@
253253
expect(upload[:status_code]).to eq(200)
254254

255255
end
256+
257+
it "test_upload_with_checks" do
258+
request_obj = double
259+
allow(ImageKitIo::Request)
260+
.to receive(:new)
261+
.with(private_key, public_key, url_endpoint)
262+
.and_return(request_obj)
263+
264+
allow(request_obj)
265+
.to receive(:create_headers)
266+
.and_return({})
267+
@ac={}
268+
allow(request_obj)
269+
.to receive(:request){|method,url,headers,payload| @ac={method: method, url: url, headers: headers, payload:payload}}
270+
.and_return({status_code: 200})
271+
272+
SUT = file_api_service.new(request_obj)
273+
274+
upload = SUT.upload(file: "./fake_file.jpg", file_name: "my_file_name", checks: '"file.size" < "1mb"')
275+
276+
expect(@ac[:payload]['checks']).to eq('"file.size" < "1mb"')
277+
278+
expect(upload[:status_code]).to eq(200)
279+
280+
end
256281
end
257282

258283
describe 'FileListTest' do

0 commit comments

Comments
 (0)