GitHub user dr3s added a comment to the discussion: Operator concurrency

hey thanks for the quick reply.   yeah I have the await.  It just was cut off 
in my question.

```rust
pub async fn upload_image(state: &AppState, id: &str, file_path: &str, file: 
Bytes) -> Result<Bytes> {
    let cursor = Cursor::new(&file);
    
    // Create JPEG decoder
    let mut decoder = JpegDecoder::new(cursor)?;
    
    // Read EXIF from decoder's metadata
    let orientation = decoder.orientation()?;

    // Create DynamicImage from decoder
    let mut img = DynamicImage::from_decoder(decoder)?;
    
    // Apply rotation based on EXIF orientation
    img = match orientation {
        Orientation::FlipHorizontal => img.fliph(),
        Orientation::Rotate180 => img.rotate180(),
        Orientation::FlipVertical => img.flipv(),
        Orientation::Rotate90FlipH => img.fliph().rotate90(),
        Orientation::Rotate90 => img.rotate90(),
        Orientation::Rotate270FlipH => img.fliph().rotate270(),
        Orientation::Rotate270 => img.rotate270(),
        _ => img  // orientation 1 or unknown
    };

    // Pre-allocate buffer for the processed image
    let mut jpeg_bytes = Vec::with_capacity(file.len());
    
    {
        let mut cursor = Cursor::new(&mut jpeg_bytes);
        // Resize the corrected image
        img.resize(800, 600, image::imageops::FilterType::Lanczos3)
           .write_to(&mut cursor, image::ImageFormat::Jpeg)?;
    }

    let bytes = Bytes::from(jpeg_bytes);

    println!("Uploading {} to Blob storage", id);
    state.storage.write(file_path, bytes.clone()).await?;
    
    println!("Uploaded {}", id);
    
    Ok(bytes)
}
```

GitHub link: 
https://github.com/apache/opendal/discussions/5401#discussioncomment-11486813

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to