File uploading made easy

Leverage direct client and server side file upload without managing storage

Code snippets

Powerful upload APIs

Client-side and server-side SDKs for different languages and frameworks to help you get started right away.

cURL
React
Angular
Vue.js
Android (kotlin)
Android (java)
Javascript
Python
Node.js
Ruby and ROR
Java
PHP
.NET
curl -X POST "https://upload.imagekit.io/api/v1/files/upload"\
-u your_private_api_key:\
-F 'file=@/Users/username/Desktop/my_file_name.jpg;type=image/jpg'\
-F 'fileName=my_file_name.jpg'
// In order to use the SDK, you need to provide it with a few configuration parameters. 
// The configuration parameters can be applied directly to the IKImage component or using 
// an IKContext component.
  
<IKContext
	publicKey="your_public_key"
	urlEndpoint="your_url_endpoint"
	transformationPosition="path"
	authenticationEndpoint="http://www.yourserver.com/auth"
>

// Image upload
<IKUpload fileName="my-upload" />
</IKContext>
// In order to use the SDK, you need to provide it with a few configuration parameters. 
// The configuration parameters must be passed to the ImagekitioAngularModule module 
// in your app.module.ts file.
  
@NgModule({
	declarations: [
		AppComponent
	],
	imports: [
		BrowserModule,
		AppRoutingModule,
		ImagekitioAngularModule.forRoot({
			publicKey: "your_public_key", // or environment.publicKey
			urlEndpoint: "your_url_endpoint", // or environment.urlEndpoint
			authenticationEndpoint: "http://www.yourserver.com/auth" // or environment.authenticationEndpoint
		})
	],
	providers: [],
	bootstrap: [AppComponent]
})

// Simple upload
<ik-upload fileName="my-upload" /></ik-upload>

// Upload using callbacks and other parameters of upload API
<ik-upload fileName="test_new" [useUniqueFileName]="false" [isPrivateFile]="true"
	(onSuccess)="handleUploadSuccess($event)" (onError)="handleUploadError($event)"></ik-upload>
// In order to use the SDK, you need to provide it with a few configuration parameters. 
// The configuration parameters can be applied directly to the IKImage component or using an IKContext component.

<IKContext
	publicKey="your_public_key"
	urlEndpoint="your_url_endpoint"
	transformationPosition="path"
	authenticationEndpoint="http://www.yourserver.com/auth"
>

// Image upload
<IKUpload fileName="my-upload" />
</IKContext>
import com.imagekit.android.ImageKit;
  
ImageKit.init(
	context = applicationContext,
	publicKey = "your_public_key",
	urlEndpoint = "your_url_endpoint",
	transformationPosition = TransformationPosition.PATH,
	authenticationEndpoint = "http://www.yourserver.com/auth"
)

// File upload
ImageKit.getInstance().uploader().uploadImage(
	file = bitmap!!
	, fileName = filename
	, useUniqueFilename = false
	, tags = arrayOf("nice", "copy", "books")
	, folder = "/dummy/folder/"
	, imageKitCallback = this
)
import com.imagekit.android.ImageKit;
  
ImageKit.Companion.init(
	getApplicationContext(),
	"your_public_key",
	"your_url_endpoint",
	TransformationPosition.PATH,
	"http://www.yourserver.com/auth"
);

// File upload
ImageKit.Companion.getInstance().uploader().uploadImage(
	bitmap,
	filename,
	false, // useUniqueFilename
	new String[]{"nice", "copy", "books"}, // tags, 
	"/dummy/folder/", 
	imageKitCallback
)
// SDK initialization
  
var imagekit = new ImageKit({
	publicKey : "your_public_key",
	urlEndpoint : "your_url_endpoint",
	authenticationEndpoint : "http://www.yourserver.com/auth",
});

// Upload function internally uses the ImageKit.io javascript SDK
function upload(data) {
	var file = document.getElementById("file1");
	imagekit.upload({
		file : file.files[0],
		fileName : "abc1.jpg",
		tags : ["tag1"]
	}, function(err, result) {
		console.log(arguments);
		console.log(imagekit.url({
			src: result.url,
			transformation : [{ height: 300, width: 400}]
		}));
	})
}
# SDK initialization

from imagekitio import ImageKit
imagekit = ImageKit(
	private_key='your_private_key',
	public_key='your_public_key',
	url_endpoint='your_url_endpoint'
)

imagekit.upload_file(
    file= "<url|base_64|binary>", # required
    file_name= "my_file_name.jpg", # required
    options= {
        "folder" : "/example-folder/",
        "tags": ["sample-tag"],
        "is_private_file": False,
        "use_unique_file_name": True,
        "response_fields": ["is_private_file", "tags"],
    }
)

// SDK initialization
  
var ImageKit = require("imagekit");

var imagekit = new ImageKit({
	publicKey : "your_public_key",
	privateKey : "your_private_key",
	urlEndpoint : "your_url_endpoint"
});

// Using Callback Function

imagekit.upload({
    file : <url|base_64|binary>, //required
    fileName : "my_file_name.jpg",   //required
}, function(error, result) {
    if(error) console.log(error);
    else console.log(result);
});

// Using Promises 

imagekit.upload({
    file : <url|base_64|binary>, //required
    fileName : "my_file_name.jpg",   //required
}).then(response => {
    console.log(response);
}).catch(error => {
    console.log(error);
});

# Add this configuration to config/environments/development.rb and config/environments/production.rb
  
config.imagekit={
	private_key: "your_private_key",
	public_key: "your_public_key",
	url_endpoint: "your_url_endpoint"
}

imagekitio.upload_file(
    file = "<url|base_64|binary>", # required
    file_name= "my_file_name.jpg",  # required
    options= {response_fields: 'isPrivateFile, tags', tags: %w[abc def], use_unique_file_name: true,}
)

/*
	Create a config.properties file inside src/main/resources of your project. 
	And put essential values of keys (UrlEndpoint, PrivateKey, PublicKey), no need to use quote
	in values. Then you need to initialize ImageKit with that configuration.

	UrlEndpoint=your_url_endpoint
	PrivateKey=your_private_key
	PublicKey=your_public_key
*/
  
import io.imagekit.sdk.ImageKit;
import io.imagekit.sdk.config.Configuration;
import io.imagekit.sdk.utils.Utils;

class App {
	public static void main(String[] args) {
		ImageKit imageKit=ImageKit.getInstance();
		Configuration config=Utils.getSystemConfig(App.class);
		imageKit.setConfig(config);
	}
}

String filePath = "your-local-file-path";
String base64 = Utils.fileToBase64(new File(filePath));
FileCreateRequest fileCreateRequest = new FileCreateRequest(base64, "file_name.jpg");
String customCoordinates = "10,10,20,20";
fileCreateRequest.setCustomCoordinates(customCoordinates);  // optional
List<String> tags = new ArrayList<>();
tags.add("Sample-tag");
tags.add("T-shirt");
fileCreateRequest.setTags(tags); // optional
fileCreateRequest.setFileName("override_file_name.jpg");  // optional
fileCreateRequest.setFolder("sample-folder/nested-folder");  // optional
fileCreateRequest.setPrivateFile(false);  // optional
fileCreateRequest.setUseUniqueFileName(true);  // optional
List<String> responseFields=new ArrayList<>();
responseFields.add("tags");
responseFields.add("customCoordinates");
fileCreateRequest.setResponseFields(responseFields); // optional
Result result = ImageKit.getInstance().upload(fileCreateRequest);
System.out.println("======FINAL RESULT=======");
System.out.println(result);
System.out.println("Raw Response:");
System.out.println(result.getRaw());
System.out.println("Map Response:");
System.out.println(result.getMap());

// SDK initialization
  
use ImageKit\ImageKit;

$imageKit = new ImageKit(
	"your_public_key",
	"your_private_key",
	"your_url_endpoint"
);

$imageKit->uploadFiles(array(
    "file" => "your_file", // required
    "fileName" => "your_file_name.jpg", // required
    "useUniqueFileName" => false, // optional
    "tags" => array("tag1","tag2"), // optional
    "folder" => "images/folder/", // optional
    "isPrivateFile" => false, // optional
    "customCoordinates" => "10,10,100,100", // optional
    "responseFields" => "tags,customCoordinates" // optional
));

// SDK initialization
  
using Imagekit;
  
Imagekit.Imagekit imagekit = new Imagekit.Imagekit("your_public_key", "your_private_key", "your_url_endpoint", "path");
ImagekitResponse resp = await imagekit
    .FileName("my_file_name.jpg")
    .UploadAsync(<fullPath|url|base_64|binary>);

Ready-to-use upload widget

Integrate ImageKit's upload widget on your website to enable uploads directly from the user's device, Google Drive, Dropbox, and Facebook.

Upload files from the dashboard

Use the simple drag-and-drop interface to upload files in ImageKit's media library.

URLs ready for use on the web

Get a URL for every file that you upload. Use it directly on your website or app, and other platforms without worrying about image optimization and load time.