# ImageKit.io Provider

**URL:** <https://forum.rclone.org/t/imagekit-io-provider/38476>\
**Category:** Dev Discussions\
**Created:** [May 24, 2023, 3:32pm UTC](https://forum.rclone.org/t/imagekit-io-provider/38476 "2023-05-24T15:32:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahnv](https://forum.rclone.org/user_avatar/forum.rclone.org/ahnv/32/15081_2.png) [@ahnv](https://forum.rclone.org/u/ahnv)\
**Post date:** [May 24, 2023, 3:32pm UTC](https://forum.rclone.org/t/imagekit-io-provider/38476/1 "2023-05-24T15:32:31Z")

</div>

I'm working on implementing a Backend Provider for [imagekit.io](http://imagekit.io), the implementation seems rock solid till now, but I have hit a snag regarding file encoding (this is for unencrypted files)

[ImageKit.io](http://ImageKit.io) does not support anything other than alphanumeric unicode characters, how is encoding handled in rclone code?

P.S. I am currently working at ImageKit as a Tech Lead

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [May 25, 2023, 4:17pm UTC](https://forum.rclone.org/t/imagekit-io-provider/38476/2 "2023-05-25T16:17:21Z")

</div>

> [@ahnv](#):
>
> I'm working on implementing a Backend Provider for [imagekit.io](http://imagekit.io), the implementation seems rock solid till now,

Great

> [@ahnv](#):
>
> [ImageKit.io](http://ImageKit.io) does not support anything other than alphanumeric unicode characters, how is encoding handled in rclone code?

Exactly which characters are allowed / not allowed?

Rclone has an [encoding system](https://rclone.org/overview/#encoding) which allows swapping of some characters into unicode lookalikes. This may not be enough for you though.

Have you tried running [the integration tests](https://github.com/rclone/rclone/blob/master/CONTRIBUTING.md#backend-testing)? I imagine these will fail badly if you can only have `A-Z0-9`

---

<div class="post-metadata">

**Author:** ![ahnv](https://forum.rclone.org/user_avatar/forum.rclone.org/ahnv/32/15081_2.png) [@ahnv](https://forum.rclone.org/u/ahnv)\
**Post date:** [May 26, 2023, 8:28am UTC](https://forum.rclone.org/t/imagekit-io-provider/38476/3 "2023-05-26T08:28:29Z")

</div>

> [@ncw](#):
>
> Rclone has an [encoding system](https://rclone.org/overview/#encoding) which allows swapping of some characters into unicode lookalikes. This may not be enough for you though.

Thanks, I'll look into this

> [@ncw](#):
>
> Have you tried running [the integration tests](https://github.com/rclone/rclone/blob/master/CONTRIBUTING.md#backend-testing)? I imagine these will fail badly if you can only have `A-Z0-9`

That's where the issue was highlighted, we support the following characters

`A-Za-zªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛱ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢄᢇ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎↃↄⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々〆〱-〵〻〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛥꜗ-ꜟꜢ-ꞈꞋ-ꟊꟐꟑꟓꟕ-ꟙꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ﬀ-ﬆﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼＡ-Ｚａ-ｚｦ-ﾾￂ-ￇￊ-ￏￒ-ￗￚ-ￜ̀-ͯ҃-҉֑-ׇֽֿׁׂׅׄؐ-ًؚ-ٰٟۖ-ۜ۟-۪ۤۧۨ-ܑۭܰ-݊ަ-ް߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛࢘-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣঁ-ঃ়া-ৄেৈো-্ৗৢৣ৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑੰੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣஂா-ூெ-ைொ-்ௗఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣඁ-ඃ්ා-ුූෘ-ෟෲෳัิ-ฺ็-๎ັິ-ຼ່-ໍ༹༘༙༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏႚ-ႝ፝-፟ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝᠋-᠍᠏ᢅᢆᢩᤠ-ᤫᤰ-᤻ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼᪰-ᫎᬀ-ᬄ᬴-᭄᭫-᭳ᮀ-ᮂᮡ-ᮭ᯦-᯳ᰤ-᰷᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿⃐-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꙯-꙲ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣠-꣱ꣿꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀ꧥꨩ-ꨶꩃꩌꩍꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭ﬞ︀-️︠-︯0-9²³¹¼-¾٠-٩۰-۹߀-߉०-९০-৯৴-৹੦-੯૦-૯୦-୯୲-୷௦-௲౦-౯౸-౾೦-೯൘-൞൦-൸෦-෯๐-๙໐-໙༠-༳၀-၉႐-႙፩-፼ᛮ-ᛰ០-៩៰-៹᠐-᠙᥆-᥏᧐-᧚᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙⁰⁴-⁹₀-₉⅐-ↂↅ-↉①-⒛⓪-⓿❶-➓⳽〇〡-〩〸-〺㆒-㆕㈠-㈩㉈-㉏㉑-㉟㊀-㊉㊱-㊿꘠-꘩ꛦ-ꛯ꠰-꠵꣐-꣙꤀-꤉꧐-꧙꧰-꧹꩐-꩙꯰-꯹０-９d0-9²³¹¼-¾٠-٩۰-۹߀-߉०-९০-৯৴-৹੦-੯૦-૯୦-୯୲-୷௦-௲౦-౯౸-౾೦-೯൘-൞൦-൸෦-෯๐-๙໐-໙༠-༳၀-၉႐-႙፩-፼ᛮ-ᛰ០-៩៰-៹᠐-᠙᥆-᥏᧐-᧚᪀-᪉᪐-᪙᭐-᭙᮰-᮹᱀-᱉᱐-᱙⁰⁴-⁹₀-₉⅐-ↂↅ-↉①-⒛⓪-⓿❶-➓⳽〇〡-〩〸-〺㆒-㆕㈠-㈩㉈-㉏㉑-㉟㊀-㊉㊱-㊿꘠-꘩ꛦ-ꛯ꠰-꠵꣐-꣙꤀-꤉꧐-꧙꧰-꧹꩐-꩙꯰-꯹０-９l/_-`

The main issue comes is with space character, control characters `␀␁␂␃␄␅␆␇␈␉␊␋␌␍␎␏␐␑␒␓␔␕␖␗␘␙␚␛␜␝␞␟` and a couple others

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [May 26, 2023, 10:25am UTC](https://forum.rclone.org/t/imagekit-io-provider/38476/4 "2023-05-26T10:25:49Z")

</div>

> [@ahnv](#):
>
> That's where the issue was highlighted, we support the following characters

I think the rclone encoding system will not be powerful enough for you. Most cloud storage systems support the whole of unicode except for a few things like `:` or `?` which rclone can substitute.

Looking at ASCII it looks like you don't support these characters (ignoring control characters)

```auto
32  
33 !
34 "
35 #
36 $
37 %
38 &
39 '
40 (
41 )
42 *
43 +
44 ,
46 .
58 :
59 ;
60 <
61 =
62 >
63 ?
64 @
91 [
92 \
93 ]
94 ^
96 `
123 {
124 |
125 }
126 ~

```

However you don't support rclone's unicode equivalents `＊｀＼：␀␁␂␃␄␅␆␇␈␉␊␋␌␍␎␏␐␑␒␓␔␕␖␗␘␙␚␛␜␝␞␟␡＄＂＃␠～＜＞` so the standard encoding scheme won't work.

What I'd suggest you do is pick a unicode character that you do support, say `ª` (I chose this one because it is a 2 bytes when encoded into utf-8).

Then use this as an escape sequence to encode the UTF-8 character values in hex. UTF-8 is self synchonizing so there will either be 2,4,6, or 8 hex digits after the `ª`

Code point ↔ UTF-8 conversion chart from wikipedia

| First code point | Last code point | Byte 1 | Byte 2 | Byte 3 | Byte 4 |
| --- | --- | --- | --- | --- | --- |
| U+0000 | U+007F | 0xxxxxxx | | | |
| U+0080 | U+07FF | 110xxxxx | 10xxxxxx | | |
| U+0800 | U+FFFF | 1110xxxx | 10xxxxxx | 10xxxxxx | |
| U+10000 | [[b]](https://en.wikipedia.org/wiki/UTF-8#cite_note-20)U+10FFFF | 11110xxx | 10xxxxxx | 10xxxxxx | 10xxxxxx |

So something like this (in python)

```auto
>>> def encode(c): return "ª"+c.encode("utf-8").hex()
... 
>>> encode(" ")
'ª20'
>>> encode("ª")
'ªc2aa'
>>> encode("?")
'ª3f'
>>> encode("＊")
'ªefbc8a'
>>> 

```

You could encode any character you cant represent and of course the escape character `ª`

When decoding you can tell how many hex digits to expect by looking at the first hex digit

| first hex digit | total digits |
| --- | --- |
| `0-7` | 2 digits total |
| `8-b` | invalid |
| `c-d` | 4 digits total |
| `e` | 6 digits total |
| `f` | 8 digits total |

There are probably more efficient encoding schemes but that may be good enough and it is quite simple. Do you have a length limit on file names?

---

<div class="post-metadata">

**Author:** ![ahnv](https://forum.rclone.org/user_avatar/forum.rclone.org/ahnv/32/15081_2.png) [@ahnv](https://forum.rclone.org/u/ahnv)\
**Post date:** [May 29, 2023, 12:28pm UTC](https://forum.rclone.org/t/imagekit-io-provider/38476/5 "2023-05-29T12:28:03Z")

</div>

> [@ncw](#):
>
> What I'd suggest you do is pick a unicode character that you do support, say `ª` (I chose this one because it is a 2 bytes when encoded into utf-8).
> 
> Then use this as an escape sequence to encode the UTF-8 character values in hex. UTF-8 is self synchonizing so there will either be 2,4,6, or 8 hex digits after the `ª`

I'll look into this, I was able to encode all unsupported characters to `_` like it is done by the upload logic, but as per my understand of the code, the test cases are written in a way where they are strict in their assertions

> [@ncw](#):
>
> There are probably more efficient encoding schemes but that may be good enough and it is quite simple. Do you have a length limit on file names?

There is a very generous limit of 2048 characters on the backend, so it shouldn't be a problem

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [July 29, 2023, 8:28am UTC](https://forum.rclone.org/t/imagekit-io-provider/38476/6 "2023-07-29T08:28:23Z")

</div>

Closed on July 29, 2023, 8:28am UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
