Answers for "from image url to base64"

2

img src data base64

<img src="data:image/png;base64,..." /> <!-- Replace png with the mime type of the image --!>
Posted by: Guest on March-01-2021
0

uploading base64 image

// Create a source file client
ShareFileClient dirClient = new ShareFileClientBuilder()
    .endpoint("https://xxx.file.core.windows.net")
    .shareName("xxx")
    .credential(new StorageSharedKeyCredential("xxx", "xxx"))
    .resourcePath("photos" + "/" + "test.png")
    .buildFileClient();

var base64Image = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";

// Create a source file
try {
    var sizeInBytes = 4 * Math.ceil(base64Image.length() / 3)*0.5624896334383812;
    dirClient.create((long) sizeInBytes);
} catch (ShareStorageException e) {
    System.out.println("Failed to create source client. Reasons: " + e.getMessage());
}

// decodeBase64
byte[] bytes = Base64.decodeBase64(base64Image);

// Upload
try (ByteArrayInputStream dataStream = new ByteArrayInputStream(bytes)) {
    dirClient.upload(dataStream, bytes.length);
} catch (IOException e) {
    e.printStackTrace();
}
Posted by: Guest on January-16-2022

Code answers related to "from image url to base64"

Browse Popular Code Answers by Language