into-stream | Convert a | Runtime Evironment library
kandi X-RAY | into-stream Summary
kandi X-RAY | into-stream Summary
Convert a string/promise/array/iterable/asynciterable/buffer/typedarray/arraybuffer/object into a stream
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of into-stream
into-stream Key Features
into-stream Examples and Code Snippets
Community Discussions
Trending Discussions on into-stream
QUESTION
I believe I have a very simple requirement for which a solution has befuddled me. I am new to the azure-python-sdk and have had little success with its new blob streaming functionality.
Some contextI have used the Java SDK for several years now. Each CloudBlockBlob object has a BlobInputStream and a BlobOutputStream object. When a BlobInputStream
is opened, one can invoke its many functions (most notably its read() function) to retrieve data in a true-streaming fashion. A BlobOutputStream
, once retrieved, has a write(byte[] data) function where one can continuously write data as frequently as they want until the close() function is invoked. So, it was very easy for me to:
- Get a
CloudBlockBlob
object, open it'sBlobInputStream
and essentially get back anInputStream
that was 'tied' to theCloudBlockBlob
. It usually maintained 4MB of data - at least, that's what I understood. When some amount of data is read from its buffer, a new (same amount) of data is introduced, so it always has approximately 4MB of new data (until all data is retrieved). - Perform some operations on that data.
- Retrieve the
CloudBlockBlob
object that I am uploading to, get it'sBlobOutputStream
, and write to it the data I did some operations on.
A good example of this is if I wanted to compress a file. I had a GzipStreamReader
class that would accept an BlobInputStream
and an BlobOutputStream
. It would read data from the BlobInputStream
and, whenever it has compressed some amount of data, write to the BlobOutputStream
. It could call write() as many times as it wished; when it finishes reading all the daya, it would close both Input and Output streams, and all was good.
Now, the Python SDK is a little different, and obviously for good reason; the io
module works differently than Java's InputStream
and OutputStream
classes (which the Blob{Input/Output}Stream
classes inherit from. I have been struggling to understand how streaming truly works in Azure's python SDK. To start out, I am just trying to see how the StorageStreamDownloader class works. It seems like the StorageStreamDownloader
is what holds the 'connection' to the BlockBlob
object I am reading data from. If I want to put the data in a stream, I would make a new io.BytesIO()
and pass that stream to the StorageStreamDownloader
's readinto method.
For uploads, I would call the BlobClient's upload method. The upload method accepts a data
parameter that is of type Union[Iterable[AnyStr], IO[AnyStr]]
.
I don't want to go into too much detail about what I understand, because what I understand and what I have done have gotten me nowhere. I am suspicious that I am expecting something that only the Java SDK offers. But, overall, here are the problems I am having:
- When I call download_blob, I get back a
StorageStreamDownloader
with all the data in the blob. Some investigation has shown that I can use theoffset
andlength
to download the amount of data I want. Perhaps I can call it once with adownload_blob(offset=0, length=4MB)
, process the data I get back, then again calldownload_bloc(offset=4MB, length=4MB)
, process the data, etc. This is unfavorable. The other thing I could do is utilize themax_chunk_get_size
parameter for theBlobClient
and turn on thevalidate_content
flag (make it true) so that theStorageStreamDownloader
only downloads 4mb. But this all results in several problems: that's not really streaming from astream
object. I'll still have to calldownload
andreadinto
several times. And fine, I would do that, if it weren't for the second problem: - How the heck do I stream an upload? The upload can take a stream. But if the stream doesn't auto-update itself, then I can only upload once, because all the blobs I deal with must be
BlockBlobs
. The docs for theupload_function
function say that I can provide a paramoverwrite
that does:
keyword bool overwrite: Whether the blob to be uploaded should overwrite the current data. If True, upload_blob will overwrite the existing data. If set to False, the operation will fail with ResourceExistsError. The exception to the above is with Append blob types: if set to False and the data already exists, an error will not be raised and the data will be appended to the existing blob. If set overwrite=True, then the existing append blob will be deleted, and a new one created. Defaults to False.
- And this makes sense because
BlockBlobs
, once written to, cannot be written to again. So AFAIK, you can't 'stream' an upload. If I can't have a stream object that is directly tied to the blob, or holds all the data, then the upload() function will terminate as soon as it finishes, right?
Okay. I am certain I am missing something important. I am also somewhat ignorant when it comes to the io
module in Python. Though I have developed in Python for a long time, I never really had to deal with that module too closely. I am sure I am missing something, because this functionality is very basic and exists in all the other azure SDKs I know about.
Everything I said above can honestly be ignored, and only this portion read; I am just trying to show I've done some due diligence. I want to know how to stream data from a blob, process the data I get in a stream, then upload that data. I cannot be receiving all the data in a blob at once. Blobs are likely to be over 1GB and all that pretty stuff. I would honestly love some example code that shows:
- Retrieving some data from a blob (the data received in one call should not be more than 10MB) in a stream.
- Compressing the data in that stream.
- Upload the data to a blob.
This should work for blobs of all sizes; whether its 1MB or 10MB or 10GB should not matter. Step 2 can be anything really; it can also be nothing. Just as long as long as data is being downloaded, inserted into a stream, then uploaded, that would be great. Of course, the other extremely important constraint is that the data per 'download' shouldn't be an amount more than 10MB.
I hope this makes sense! I just want to stream data. This shouldn't be that hard.
Edit:
Some people may want to close this and claim the question is a duplicate. I have forgotten to include something very important: I am currently using the newest, mot up-to-date azure-sdk version. My azure-storage-blob
package's version is 12.5.0
. There have been other questions similar to what I have asked for severely outdated versions. I have searched for other answers, but haven't found any for 12+
versions.
ANSWER
Answered 2021-Mar-15 at 02:53If you want to download azure blob in chunk, process every chunk data and upload every chunk data to azure blob, please refer to the follwing code
QUESTION
I need some guidance. My Azure function (written in node.js) will convert some random text to speech and then upload the speech output to a Blob. I will like to do so without using an intermediate local file. BlockBLobClient.upload method requires a Blob, string, ArrayBuffer, ArrayBufferView or a function which returns a new Readable stream, and also the content length. I am not able to get these from the RequestPromise object returned by call to TTS (As of now I am using request-promise to call TTS). Any suggestions will be really appreciated.
Thank you
Adding a code sample that can be tested as "node TTSSample.js" Sample code is based on
Azure Blob stream related code shared at https://github.com/Azure-Samples/azure-sdk-for-js-storage-blob-stream-nodejs/blob/master/v12/routes/index.js
Azure Text to speech sample code at https://github.com/Azure-Samples/Cognitive-Speech-TTS/tree/master/Samples-Http/NodeJS
Replace appropriate keys and parameters in the enclosed settings.js
I am using node.js runtime v12.18.3
Input text and the output blob name are hard coded in this code sample.
...
ANSWER
Answered 2020-Sep-10 at 06:14Regarding the issue, please refer to the following code
QUESTION
I have videos saved in azure blob storage and i want to upload them into facebook. Facebook video upload is a multipart/form-data post request. Ordinary way of doing this is download azure blob as bytes using readall() method in azure python sdk and set it in requests post data as follows.
...ANSWER
Answered 2020-Jul-22 at 06:09Regarding how to upload video in chunk with stream, please refer to the following code
QUESTION
So I'm trying to have my code read text in from a file and display it in a scrollView, with a stationary label at the top. Think of an e-reader, where the book's title is pinned to the top of the screen, but the content scrolls. I've copied the text verbatim from an example in the "Creating Mobile Apps with Xamarin" book that I downloaded from Xamarin's website. However, when I run my code, no text is displayed; the screen just shows blank white, as though the app is running on the emulator, but has no code assigned to it. Using Visual Studio's debugger, I stepped into the code and realized that, for some reason, the variable "stream" is not being assigned a value -- its value is null, according to the debugger, which is causing a "value cannot be null" exception. This is only the second code I've tried to make with Xamarin Forms, using the book as a template, and I'm just stumped on why "stream" is not being assigned a value. Hopefully one of you lovely people can help me out!
If it would help to see the code I'm referencing, that can be found in the book available for download from Microsoft here, on pages 105-106 of the PDF (or pages 84-85, if you're going by the book's page numbers).
Things I've tried:
- I've used assembly.GetManifestResourceNames() to make sure I'm typing the resource ID correctly. I originally had it as "ereader.Texts.JP.txt" because the program itself is called cdern_lab10, and I thought that was the namespace. However, GetManifestResourceNames() returned "JP.Texts.JP.txt", so I changed it.
- I've double-checked to make sure the resource is marked as an embedded resource, and it is. I've also deleted and re-added the resource, and checked again to make sure it's embedded. It's stored in a folder within the project named "Texts".
Note: There was a similar question asked on here about a year ago (here), but it appears it was never really answered.
...ANSWER
Answered 2018-Mar-25 at 21:23You can try something like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install into-stream
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page