locked
Download several directories from blob azure storage in Kotlin and ZIP Them RRS feed

  • Question

  • I am trying to download 2 directories from blob azure storage as bytearray and compress them to zip but i got an error. I saw in web that directory does not really exist in blob storage... I did not really understand how it works so...

    Here is my code below :


     val dstsData = "/projections/$projectionId/inputs/datasources"
        val dstsAss = "/projections/$projectionId/inputs/assumptions"
        val dstsDL = "${inputDispatchPath}inputs.zip"
    
        val inputsDatasources = withContext(Dispatchers.IO) {
            azureBatch.filesystem.downloadAsByteArray(dstsData)
        }
        val inputsAssumptions = withContext(Dispatchers.IO) {
            azureBatch.filesystem.downloadAsByteArray(dstsAss)
        }
    
        val baos = ByteArrayOutputStream()
        val zipOutputStream = ZipOutputStream(baos)
    
        val entry = ZipEntry("inputs.zip")
        entry.size = inputsDatasources.size.toLong() + inputsAssumptions.size.toShort()
    
        withContext(Dispatchers.IO){
            zipOutputStream.putNextEntry(entry)
            zipOutputStream.write(inputsDatasources)
            zipOutputStream.write(inputsAssumptions)
            zipOutputStream.closeEntry()
            zipOutputStream.close()
        }
    
        val file = ezEventBus.request(
            ServiceIORequest.WriteURLFor(
                user,
                dstsDL,
                baos.toByteArray().size.toLong()
            ),
            correlationId
        )
        file .uploader.upload(
            vertx,
            webClient,
            Buffer.buffer(baos.toByteArray()),
            baos.toByteArray().size.toLong())

    Do you have an idea? Thanks a lot

    Regards

    Here is my link to my stackoverflow question: 


    • Edited by ShikaZer0 Wednesday, December 30, 2020 11:18 AM
    • Moved by Dave PatrickMVP Wednesday, December 30, 2020 1:24 PM looking for forum
    Wednesday, December 30, 2020 10:56 AM

Answers

  • I'd try asking for help over here.

    azure-blob-storage - Microsoft Q&A

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Wednesday, December 30, 2020 1:24 PM