Uploading image files to managed folder

Buse
Buse Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 4

Hello,

I need to pull images from a folder, transform it and upload it to another folder using python script.

I pulled and transformed the images but I have trouble saving to destination folder. upload_data takes binary data not image data. Other upload methods requires "local file path"

Anyway other method I can use?

Thank you

Best Answer

  • DanDy
    DanDy Dataiker, Dataiku DSS Core Designer, Registered Posts: 8 Dataiker
    edited July 17 Answer ✓

    You could use some code similar to this sample code:

    import dataiku, io
    from PIL import Image
    import numpy as np
    ​
    a = np.asarray(img)
    img1 = Image.fromarray(a,'RGB')
    
    buf=io.BytesIO()
    img1.save(buf, format='PNG')
    
    folder_handle = dataiku.Folder("3wglEqHl")
    folder_handle.upload_stream("/Monimage7.jpg", buf.getvalue())

Answers

Setup Info
    Tags
      Help me…