Wednesday, 1 December 2021

Can I send binary fles using the SimpleHttpOperator in Airflow?

I would like to upload binary data with a REST API using an Airflow's SimpleHttpOperator.
With python's requests, I would do that by doing

upload_response = requests.put(
        upload_url, data=Path(f"{filename}").read_bytes(), headers=headers
    )

In Airflow I have a first task downloading the file with an SFTPOperator and then trying to upload it with the SimpleHttpOperator:

get_file = SFTPOperator(
        task_id         = 'get_file',
        ssh_conn_id     = 'my_sftp_conn',
        remote_filepath = f"{templ_remote_filepath}/{filename}",
        local_filepath  = f"{basepath}/{filename}",
        operation       = 'GET',
    )

upload_file = SimpleHttpOperator(
        task_id      = 'upload_file',
        http_conn_id = "my_http_conn",
        endpoint     = get_upload_url.output,
        method       = 'PUT',
        headers      = {"Content-MD5": md5_hash_b64, "Content-Type": "application/text"},
        data         = Path(get_file.output).read_bytes(),
        log_response = True,
    )

I would like to be able to input get_file.output (the downloaded filepath) as a string instead of an XComArgs as it is. How can I do this?



from Can I send binary fles using the SimpleHttpOperator in Airflow?

Slick.js Error: Cannot read properties of null (reading 'add')

I am using Laravel 5.8 and Slick.js to show an Slideshow for my Online Store and I coded this:

Slick.prototype.initADA = function() {
        var _ = this,
                numDotGroups = Math.ceil(_.slideCount / _.options.slidesToShow),
                tabControlIndexes = _.getNavigableIndexes().filter(function(val) {
                    return (val >= 0) && (val < _.slideCount);
                });

        _.$slides.add(_.$slideTrack.find('.slick-cloned')).attr({
            'aria-hidden': 'true',
            'tabindex': '-1'
        }).find('a, input, button, select').attr({
            'tabindex': '-1'
        });

        if (_.$dots !== null) {
            _.$slides.not(_.$slideTrack.find('.slick-cloned')).each(function(i) {
                var slideControlIndex = tabControlIndexes.indexOf(i);

                $(this).attr({
                    'role': 'tabpanel',
                    'id': 'slick-slide' + _.instanceUid + i,
                    'tabindex': -1
                });

                if (slideControlIndex !== -1) {
                   var ariaButtonControl = 'slick-slide-control' + _.instanceUid + slideControlIndex
                   if ($('#' + ariaButtonControl).length) {
                     $(this).attr({
                         'aria-describedby': ariaButtonControl
                     });
                   }
                }
            });

            _.$dots.attr('role', 'tablist').find('li').each(function(i) {
                var mappedSlideIndex = tabControlIndexes[i];

                $(this).attr({
                    'role': 'presentation'
                });

                $(this).find('button').first().attr({
                    'role': 'tab',
                    'id': 'slick-slide-control' + _.instanceUid + i,
                    'aria-controls': 'slick-slide' + _.instanceUid + mappedSlideIndex,
                    'aria-label': (i + 1) + ' of ' + numDotGroups,
                    'aria-selected': null,
                    'tabindex': '-1'
                });

            }).eq(_.currentSlide).find('button').attr({
                'aria-selected': 'true',
                'tabindex': '0'
            }).end();
        }

        // for loop code goes here ...

        _.activateADA();

    };

Now the Slideshow does not show up correctly and showed me this errors at Console:

Uncaught TypeError: _.initADA is not a function
    at Slick.init 
    at new Slick 
    at jQuery.fn.init.$.fn.slick 
    at HTMLDocument.<anonymous> 
    at mightThrow 
    at process

And here is the result:

capture

However, it should be shown like this:

capture2

So what's going wrong here? How can I fix this issue?

And here is the html for that:

<div class="slider-slick-img container">
    <div class="slider-for slick-initialized slick-slider">
        <div class="slick-list draggable">
            <div class="slick-track" style="opacity: 1; width: 283px;">
                <div class="slick-slide slick-current slick-active" data-slick-index="0" aria-hidden="false" style="width: 283px; position: relative; right: 0px; top: 0px; z-index: 999; opacity: 1;">
                    <div>
                        @if(!empty($gallery))
                            @forelse($gallery as $path)
                                <div class="item" style="width: 100%; display: inline-block;">
                                    <img src="" alt="image"  draggable="false"/>
                                </div>
                            @empty
                            @endforelse
                        @endif
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="slider-nav mt-5 slick-initialized slick-slider">
        <div class="slick-list draggable" style="padding: 0px 50px;">
            <div class="slick-track" style="opacity: 1; width: 61px; transform: translate3d(-61px, 0px, 0px);">
                <div class="slick-slide slick-current slick-center" data-slick-index="0" aria-hidden="true" style="width: 61px;">
                    <div>
                        @if(count($gallery) > 1)
                            @if(!empty($gallery))
                                @forelse($gallery as $path)
                                    <div class="item px-2" style="width: 100%; display: inline-block;">
                                        <img src="" alt="image" draggable="false"/>
                                    </div>
                                @empty
                                @endforelse
                            @endif
                        @endif
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


from Slick.js Error: Cannot read properties of null (reading 'add')

null is not an object (evaluating 'RCTAsyncStorage.multiMerge')

I recently upgraded to Expo SDK 43.

I am now getting this error:

The line of code throwing it is:

if (!RCTAsyncStorage.multiMerge) {

I am on the latest version of AsyncStorage.

This seems to be due to my usage of firebase-js-sdk.

Unfortunately as this is an iOS/Android/Web project, it's necessary.

When I mock my Firebase exports, everything works:

const auth = () => {};

const analytics = () => {};

export default { auth, analytics };

But when I use the firebase-js-sdk functions, I get the above message.

This code causes an error (whichever version of auth I use)

let auth = initializeAuth(config, {
  persistence: getReactNativePersistence(AsyncStorage),
});
//let auth = getAuth(config);
let analytics = getAnalytics(config);

export default { auth, analytics };


from null is not an object (evaluating 'RCTAsyncStorage.multiMerge')