Skip to content

Commit 552ee9a

Browse files
authored
readme fix
1 parent 0fb8d5c commit 552ee9a

File tree

1 file changed

+43
-44
lines changed

1 file changed

+43
-44
lines changed

README.md

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
99
[![Twitter Follow](https://img.shields.io/twitter/follow/imagekitio?label=Follow&style=social)](https://twitter.com/ImagekitIo)
1010

11-
ImageKit gem for Ruby on Rails that allows you to use real-time [image resizing](https://docs.imagekit.io/features/image-transformations), [optimization](https://docs.imagekit.io/features/image-optimization), and [file uploading](https://docs.imagekit.io/api-reference/upload-file-api/).
11+
Ruby on Rails gem for [ImageKit](https://imagekit.io/) implements the new APIs and interface for different file operations.
12+
13+
ImageKit is complete media storage, optimization, and transformation solution that comes with an [image and video CDN](https://imagekit.io/features/imagekit-infrastructure). It can be integrated with your existing infrastructure - storage like AWS S3, web servers, your CDN, and custom domain names, allowing you to deliver optimized images in minutes with minimal code changes.
1214

1315
Table of contents -
1416
* [Installation](#Installation)
@@ -155,20 +157,17 @@ imagekitio:
155157

156158
## Usage
157159

158-
You can use this Ruby SDK for three different methods - URL generation, file upload, and file management.
160+
You can use this Ruby SDK for three different methods - URL generation, file upload, and media management operations. The usage of the SDK has been explained below.
159161

160-
The usage of the SDK has been explained below.
162+
* `URL Generation`
163+
* `File Upload`
164+
* `File Management`
161165

162166
## URL generation
163167

164168
**1. Using Image path and image hostname or endpoint**
165169

166-
This method allows you to create a URL using the path where the image exists and the URL
167-
endpoint(url_endpoint) you want to use to access the image. You can refer to the documentation
168-
[here](https://docs.imagekit.io/integration/url-endpoints) to read more about URL endpoints
169-
in ImageKit and the section about [image origins](https://docs.imagekit.io/integration/configure-origin) to understand
170-
about paths with different kinds of origins.
171-
170+
This method allows you to create an URL to access a file using the relative file path and the ImageKit URL endpoint (`urlEndpoint`). The file can be an image, video or any other static file supported by ImageKit.
172171

173172
```ruby
174173
imagekitio = ImageKitIo.client
@@ -185,8 +184,7 @@ https://ik.imagekit.io/your_imagekit_id/endpoint/tr:h-300,w-400,ar-4-3,q-40/defa
185184
```
186185

187186
**2.Using full image URL**
188-
This method allows you to add transformation parameters to an existing, complete URL already mapped to ImageKit using the `src` parameter. This method should be used if you have the complete image URL mapped to ImageKit stored in your
189-
database.
187+
This method allows you to add transformation parameters to an absolute URL. For example, if you have configured a custom CNAME and have absolute asset URLs in your database or CMS, you will often need this.
190188

191189

192190
```ruby
@@ -286,8 +284,7 @@ https://ik.imagekit.io/your_imagekit_id/tr:h-300,w-400/default-image.jpg?v=123&i
286284

287285
**List of transformations**
288286

289-
The complete list of transformations supported and their usage in ImageKit can be found [here](https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations).
290-
The SDK gives a name to each transformation parameter, making the code simpler, making the code simpler, and readable.
287+
The complete list of transformations supported and their usage in ImageKit can be found [here](https://docs.imagekit.io/features/image-transformations/resize-crop-and-other-transformations). The SDK gives a name to each transformation parameter, making the code simpler, making the code simpler, and readable.
291288

292289
If a transformation is supported in ImageKit, but a name for it cannot be found in the table below, then use the transformation code from ImageKit docs as the name when using the `url` function.
293290

@@ -385,7 +382,7 @@ be `None`.
385382
The SDK provides a simple interface for all the [media APIs mentioned here](https://docs.imagekit.io/api-reference/media-api)
386383
to manage your files. This also returns `error` and `result`. The `error` will be `None` if API succeeds.
387384

388-
**1. List & Search Files**
385+
**List & Search Files**
389386

390387
Accepts an object specifying the parameters to be used to list and search files. All parameters specified
391388
in the [documentation here](https://docs.imagekit.io/api-reference/media-api/list-and-search-files#list-and-search-file-api) can be passed with the
@@ -397,7 +394,7 @@ imagekitio.list_files(
397394
limit: 5
398395
)
399396
```
400-
**2. Get File Details**
397+
**Get File Details**
401398
Accepts the file ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-details)
402399

403400
```ruby
@@ -406,15 +403,15 @@ imagekitio.get_file_details(
406403
)
407404
```
408405

409-
**3. Get File Metadata**
406+
**Get File Metadata**
410407
Accepts the file ID and fetches the metadata as per the [API documentation here](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-for-uploaded-media-files)
411408
```ruby
412409
imagekit.get_file_metadata(
413410
file_id: '598821f949c0a938d57563bd'
414411
)
415412
```
416413

417-
**3. Get File Metadata from remote url**
414+
**Get File Metadata from remote url**
418415
Accepts the remote file url and fetches the metadata as per the [API documentation here](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-from-remote-url)
419416

420417
```ruby
@@ -423,7 +420,7 @@ imagekit.get_remote_file_url_metadata(
423420
)
424421
```
425422

426-
**4. Update File Details**
423+
**Update File Details**
427424
Update parameters associated with the file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/update-file-details).
428425
The first argument to the `update_field_details` method is the file ID, and a second argument is an object with the
429426
parameters to be updated.
@@ -436,7 +433,7 @@ imagekitio.update_file_details(
436433
)
437434
```
438435

439-
**5. Copy File**
436+
**Copy File**
440437

441438
Copy file from one path to another path using the source file path and the destination path as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/copy-file)
442439

@@ -448,7 +445,7 @@ imagekitio.copy_file(
448445
)
449446
```
450447

451-
**6. Move File**
448+
**Move File**
452449

453450
Move file from one folder to another folder using the source file path and destination path as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/move-file)
454451

@@ -459,7 +456,7 @@ imagekitio.move_file(
459456
)
460457
```
461458

462-
**7. Rename File**
459+
**Rename File**
463460

464461
Rename file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/rename-file)
465462

@@ -471,7 +468,7 @@ imagekitio.rename_file(
471468
)
472469
```
473470

474-
**8. Delete File**
471+
**Delete File**
475472

476473
Delete a file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-file). The method accepts the file ID of the file that has to be deleted.
477474

@@ -480,7 +477,7 @@ imagekitio.delete_file(
480477
file_id: '598821f949c0a938d57563bd'
481478
)
482479
```
483-
**9. File versions**
480+
**File versions**
484481

485482
Get all file versions as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-versions). The method accepts the file ID of the file.
486483

@@ -489,7 +486,7 @@ imagekitio.file_versions(
489486
file_id: '598821f949c0a938d57563bd'
490487
)
491488
```
492-
**10. File version details**
489+
**File version details**
493490

494491
Get all file version detail as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-version-details). The method accepts the file ID and version ID of the file.
495492

@@ -500,7 +497,7 @@ imagekitio.file_version_detail(
500497
)
501498
```
502499

503-
**11. Delete file version**
500+
**Delete file version**
504501

505502
Delete file version as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-file-version). The method accepts the file ID and version ID of the file.
506503

@@ -511,7 +508,7 @@ imagekitio.delete_file_version(
511508
)
512509
```
513510

514-
**12. Restore file version**
511+
**Restore file version**
515512

516513
Restore deleted file version as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/restore-file-version). The method accepts the file ID and version ID of the file.
517514

@@ -522,7 +519,7 @@ imagekitio.restore_file_version(
522519
)
523520
```
524521

525-
**13. Bulk File Delete by IDs**
522+
**Bulk File Delete by IDs**
526523

527524
Delete a file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-files-bulk). The method accepts a list of file IDs of files that has to be
528525
deleted.
@@ -533,7 +530,7 @@ imagekitio.delete_bulk_files(
533530
)
534531
```
535532

536-
**14. Purge Cache**
533+
**Purge Cache**
537534
Programmatically issue a clear cache request as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache).
538535
Accepts the full URL of the file for which the cache has to be cleared.
539536

@@ -542,7 +539,7 @@ imagekitio.purge_file_cache(
542539
file_url: 'https://ik.imagekit.io/demo/logo-white_SJwqB4Nfe.png'
543540
)
544541
```
545-
**15. Purge Cache Status**
542+
**Purge Cache Status**
546543

547544
Get the purge cache request status using the request ID returned when a purge cache request gets submitted as per the
548545
[API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache-status)
@@ -553,7 +550,7 @@ imagekitio.purge_file_cache_status(
553550
)
554551
```
555552

556-
**16. Add Bulk Tags**
553+
**Add Bulk Tags**
557554

558555
Add multiple tags on multiple files using an array of file ids and an array of tags as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/add-tags-bulk)
559556

@@ -564,7 +561,7 @@ imagekitio.add_bulk_tags(
564561
)
565562
```
566563

567-
**17. Delete Bulk Tags**
564+
**Delete Bulk Tags**
568565

569566
Remove multiple tags from multiple files using an array of file ids and an array of tags as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/remove-tags-bulk)
570567

@@ -575,7 +572,7 @@ imagekitio.delete_bulk_tags(
575572
)
576573
```
577574

578-
**18. Delete Bulk Ai Tags**
575+
**Delete Bulk AI Tags**
579576

580577
Delete bulk ai tags as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/remove-aitags-bulk)
581578

@@ -586,7 +583,7 @@ imagekitio.delete_bulk_ai_tags(
586583
)
587584
```
588585

589-
**19. Create Folder**
586+
**Create Folder**
590587

591588
Create folder as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/create-folder)
592589

@@ -598,7 +595,7 @@ imagekitio.create_folder(
598595
```
599596

600597

601-
**20. Copy Folder**
598+
**Copy Folder**
602599

603600
Copy folder as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/copy-folder)
604601

@@ -610,7 +607,7 @@ imagekitio.copy_folder(
610607
)
611608
```
612609

613-
**21. Move Folder**
610+
**Move Folder**
614611

615612
Move folder as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/move-folder)
616613

@@ -621,7 +618,7 @@ imagekitio.move_folder(
621618
)
622619
```
623620

624-
**22. Delete Folder**
621+
**Delete Folder**
625622

626623
Delete folder as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-folder)
627624

@@ -631,7 +628,7 @@ imagekitio.delete_folder(
631628
)
632629
```
633630

634-
**23. Bulk Job Status**
631+
**Bulk Job Status**
635632

636633
Get the bulk job status as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/copy-move-folder-status)
637634

@@ -641,7 +638,7 @@ imagekitio.bulk_job_status(
641638
)
642639
```
643640

644-
**24. Create Custom Metadata Fields**
641+
**Create a custom metadata field**
645642

646643
Create custom metadata fields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field)
647644

@@ -658,7 +655,7 @@ imagekitio.create_custom_metadata_field(
658655
)
659656
```
660657

661-
**25. Get Custom Metadata Fields**
658+
**Get Custom Metadata Fields**
662659

663660
Get the custom metadata fields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/get-custom-metadata-field)
664661

@@ -668,7 +665,7 @@ imagekitio.get_custom_metadata_fields(
668665
)
669666
```
670667

671-
**26. Update Custom Metadata Fields**
668+
**Update Custom Metadata Fields**
672669

673670
Update custom metadata fields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/update-custom-metadata-field)
674671

@@ -680,7 +677,7 @@ imagekitio.update_custom_metadata_field(
680677
)
681678
```
682679

683-
**27. Delete Custom Metadata Fields**
680+
**Delete Custom Metadata Fields**
684681

685682
Delete custom metadata fields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/delete-custom-metadata-field)
686683

@@ -692,7 +689,7 @@ imagekitio.delete_custom_metadata_field(
692689

693690
## Access request-id, other response headers and HTTP status code
694691

695-
Each file management function returns a hash with response, error, status, headers, raw_body keys with respective values.
692+
Each media management function returns a hash with `response`, `error`, `status_code`, `headers`, `raw_body` keys with respective values.
696693

697694
```ruby
698695
upload = imagekitio.upload_file(
@@ -704,8 +701,9 @@ upload = imagekitio.upload_file(
704701
use_unique_file_name: false,
705702
is_private_file: true
706703
)
707-
puts upload[:status] # 200
704+
puts upload[:status_code] # 200
708705
puts upload[:headers]
706+
709707
# {
710708
# "access-control-allow-origin"=>["*"],
711709
# "x-ik-requestid"=>["6963194e-014f-8945-b05a-bdb0e088f1bd"],
@@ -716,7 +714,8 @@ puts upload[:headers]
716714
# "x-request-id"=>["6963194e-014f-8945-b05a-bdb0e088f1bd"],
717715
# "connection"=>["close"]
718716
# }
719-
#
717+
718+
720719
puts upload[:raw_body]
721720
# "{\"fileId\":\"62bjf980rb886bd691b86760\",\"name\":\"default.jpg\",\"size\":102117,\"versionInfo\":{\"id\":\"62bjf980rb886bd691b86760\",\"name\":\"Version 1\"},\"filePath\":\"/test/default.jpg\",\"url\":\"https://ik.imagekit.io/46865sdf6sdf/test/default.jpg\",\"fileType\":\"image\",\"height\":700,\"width\":1050,\"thumbnailUrl\":\"https://ik.imagekit.io/46865sdf6sdf/tr:n-ik_ml_thumbnail/test/default.jpg\",\"tags\":[\"abc\",\"def\"],\"AITags\":null,\"isPrivateFile\":true,\"customCoordinates\":null,\"metadata\":{\"height\":700,\"width\":1050,\"size\":102117,\"format\":\"jpg\",\"hasColorProfile\":true,\"quality\":0,\"density\":72,\"hasTransparency\":false,\"exif\":{},\"pHash\":\"90249d9b1fc74367\"}}"
722721
```

0 commit comments

Comments
 (0)