Initial commit: immich-sdk v1.137.0

This commit is contained in:
Joakim Hulthe
2026-04-05 15:51:10 +00:00
commit 5855251f70
15 changed files with 4434 additions and 0 deletions

59
examples/upload_photos.rs Normal file
View File

@@ -0,0 +1,59 @@
//! Example: Upload photos to Immich
use immich_sdk::Client;
use std::path::Path;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client
let client = Client::from_url("https://immich.example.com")?.with_api_key("your-api-key");
// Path to the photo
let photo_path = Path::new("/path/to/your/photo.jpg");
// Upload the photo
println!("Uploading: {}", photo_path.display());
let result = client
.assets()
.upload()
.file(photo_path)
.device_asset_id("my-photo-001")
.device_id("my-computer")
.favorite()
.execute()
.await?;
match result.status {
immich_sdk::models::AssetUploadStatus::Created => {
println!("Successfully uploaded! Asset ID: {:?}", result.id);
}
immich_sdk::models::AssetUploadStatus::Duplicate => {
println!("Photo already exists (duplicate)");
}
_ => {
println!("Upload status: {:?}", result.status);
}
}
// Create an album and add the uploaded asset
if let Some(asset_id) = result.id {
let album = client
.albums()
.create()
.name("Uploaded Photos")
.execute()
.await?;
client
.albums()
.add_assets(album.id)
.asset_ids([asset_id])
.execute()
.await?;
println!("Added to album: {}", album.album_name);
}
Ok(())
}