Skip to content

Commit e866f38

Browse files
authored
Merge pull request #13 from imagekit-developer/fix_upload_dir
fix: upload dir issue
2 parents 2a75d1b + 6dac2e7 commit e866f38

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,18 @@ def options
8282
options={
8383
response_fields: 'isPrivateFile, tags',
8484
tags: %w[abc def],
85-
use_unique_file_name: false
85+
use_unique_file_name: false,
86+
folder: "your_directory/"
8687
}
8788
end
89+
90+
# If you want to set upload dir then you can use following method or you can also use options method.
91+
# This method shuld return string
92+
def store_dir
93+
"your_directory/"
94+
end
95+
96+
8897
```
8998

9099
Then you need to modify your model. for example- if your model name is employee then do these changes

lib/imagekitio.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ def filename
2929
if options!=nil
3030
@options=options
3131
end
32+
folder=nil
33+
begin
34+
folder=store_dir
35+
rescue
36+
end
37+
38+
if folder!=nil
39+
@options[:folder]=folder
40+
end
41+
3242
if self.file!=nil
3343
base64=Base64.encode64(::File.open(self.file.file, "rb").read)
3444
resp=@imagekit.upload_file(open(self.file.file,'rb'),self.file.filename,@options)
@@ -65,8 +75,12 @@ def url
6575
def options
6676
options={}
6777
end
78+
79+
def store_dir
80+
store_dir=nil
81+
end
6882
end
6983

7084
end
7185

72-
end
86+
end

0 commit comments

Comments
 (0)