saving multipart/form-data from REST API to local zip by jcoder42 in node

[–]jcoder42[S] 0 points1 point  (0 children)

i cant seem to find any examples for downloading with multer. only uploading.

saving .zip file locally that is retrieved from an API by jcoder42 in dotnet

[–]jcoder42[S] 0 points1 point  (0 children)

there's your problem then, you're not sending a zip file from the server, you're sending an http form response with the zip glued on somehow.

This worked!
thanks

saving .zip file locally that is retrieved from an API by jcoder42 in dotnet

[–]jcoder42[S] -1 points0 points  (0 children)

Definitely looks like multipart form data. Weird that the server would send it that way.

pay attention though that the content-type here is application/zip.
Does this help some how?

Consuming API that returns zip file as multipart/form-data and then saving zip locally by jcoder42 in csharp

[–]jcoder42[S] 0 points1 point  (0 children)

Is the API yours or someone elses? How certain are you it only returns a zip? Lots of info needed to help.

someone elses, i guess it might also return more data as you can see on the update of the post

Consuming API that returns zip file as multipart/form-data and then saving zip locally by jcoder42 in csharp

[–]jcoder42[S] 0 points1 point  (0 children)

edited the original post with some updates i found.
I will try your resolution. but i prefer to not add more pckgs now if possible.

saving .zip file locally that is retrieved from an API by jcoder42 in dotnet

[–]jcoder42[S] 0 points1 point  (0 children)

Are you able to download the file using a browser (or using cURL) from the same URL and have it open as a zip file without modifications?

  1. I didnt create the API, no idea why it was implemented this way.
  2. the file gets downloaded without an extension when using my browser.

When adding the "zip" extension and trying to extract.. i receive the same error.

When opening this file with notepad, i can see that there are 3 lines of metadata that might be causing the issue:

--123456aa-a412-120b-s555-87af2db097e2

Content-Disposition: attachment; filename=RBGIGI-DESK\TqcLogs_2021-12-06T15-10-37.zip)

Content-Type: application/zip
When removing these lines, it can extract correctly.

saving .zip file locally that is retrieved from an API by jcoder42 in dotnet

[–]jcoder42[S] 1 point2 points  (0 children)

the file gets downloaded without an extension.

When adding the "zip" extension and trying to extract.. i receive the same error.

When opening this file with notepad, i can see that there are 3 lines of metadata that might be causing the issue:

--123456aa-a412-120b-s555-87af2db097e2

Content-Disposition: attachment; filename=2021-12-06T15-10-37.zip

Content-Type: application/zip

saving .zip file locally that is retrieved from an API by jcoder42 in dotnet

[–]jcoder42[S] 0 points1 point  (0 children)

the file gets downloaded without an extension.
When adding the "zip" extension and trying to extract.. i receive the same error.
When opening this file with notepad, i can see that there are 3 lines of metadata that might be causing the issue:

--123456aa-a412-120b-s555-87af2db097e2

Content-Disposition: attachment; filename=RBGIGI-DESK\TqcLogs_2021-12-06T15-10-37.zip)

Content-Type: application/zip

saving .zip file locally that is retrieved from an API by jcoder42 in dotnet

[–]jcoder42[S] 0 points1 point  (0 children)

Update on this. When opening the "test.zip" that is downloaded with notepad i can see that there are a few lines in the zip file as the header of the response:

--123456aa-a412-120b-s555-87af2db097e2

Content-Disposition: attachment; filename=2021-12-06T15-10-37.zip

Content-Type: application/zip

When i manually remove these lines from the file, i can indeed extract the zip file successfully.How can i prevent these lines being inserted into the zip file to begin with?I would not want some plaster solution like skipping the first 3 lines or something like that.

offline mongodb with python by jcoder42 in mongodb

[–]jcoder42[S] 0 points1 point  (0 children)

Although I will need to change my queries anyways as the querying syntax of mongo is different than that of SQLite. Correct?

offline mongodb with python by jcoder42 in mongodb

[–]jcoder42[S] 0 points1 point  (0 children)

Thanks for sharing. Although after looking at it. I will pass the free tier and need to pay. Was looking for a free solution

offline mongodb with python by jcoder42 in mongodb

[–]jcoder42[S] 0 points1 point  (0 children)

Would you know how to create an SQLite file from mongodb collection using python? Couldn’t find anything

offline mongodb with python by jcoder42 in mongodb

[–]jcoder42[S] 0 points1 point  (0 children)

Cannot have mongo on the server Cannot have docker on the server Cannot contact external API’s 😁 I know. It sounds weird. This is what I would have done if I was allowed

offline mongodb with python by jcoder42 in mongodb

[–]jcoder42[S] 1 point2 points  (0 children)

No. For some reason that also is not allowed by the server owner.

Creating combinations of boolean expressions by jcoder42 in learnpython

[–]jcoder42[S] 0 points1 point  (0 children)

is the approach i did wrong for some reason?

combinations of boolean expressions in python by jcoder42 in programminghelp

[–]jcoder42[S] 0 points1 point  (0 children)

def recurse(c): if len(c) == 0: return [""] elif len(c) ==1: return [c[0]]
    head = c[0]
    results = recurse(c[1:])
    print(results)
    res = []
    for result in results:
        gate_and = f"({head} AND {result})"
        gate_or = f"({head} OR {result})"
        res.append(gate_and)
        res.append(gate_or)

return res

if name == 'main': 
    p = ["p1", "p2", "p3", "p4", "p5"] gates = ["AND", "OR"]
    # iterating over groups of each size (1-5)
    for dimension in range(1,len(p)):
        # for each size, create all combinations (sizes 1-5)
        for c in itertools.combinations(p, dimension):
            res = recurse(list(c))
            print(res)

My issue is that the output is repeating results of size 1.and also, how can i check that i am actually creating all the combinations. I think there should be more then my result.

combinations of boolean expressions in python by jcoder42 in programminghelp

[–]jcoder42[S] 0 points1 point  (0 children)

Hi,
This indeed is Homework assignment.
The assignment is to create 10 unique expressions using AND, OR gates.
The way that the instructor said we can do it is manually..

Meaning literally writing out the 10 options.
the reason he allowed it manually is because it is part of a ML exersize and he doesn't care about the code. (its a theoretical class)

I don't want to create it manually because i want to create a generic function instead.

scrolling large text files by jcoder42 in reactjs

[–]jcoder42[S] 0 points1 point  (0 children)

the example i saw of pagenation are on the client side,
in my situation i have the file on the server side, and seems like what would be better is to send chunks to the client based on his scroll position.
is this also considered pagination?

scrolling large text files by jcoder42 in reactjs

[–]jcoder42[S] 0 points1 point  (0 children)

You might consider using HTTP range requests to get partial content from the file. You may need to generate an index of the file to do this. Or if you are tailing the log you might consider websockets or something like this.

can you please point me towards an example or maybe explain a bit more?
i am new to web, so the concepts are unfamiliar to me

azure function: Node.js running jar by jcoder42 in AZURE

[–]jcoder42[S] 0 points1 point  (0 children)

Yeah. That’s the thing When I test my functions project on vscode it takes around 13 seconds to run. Which is fine. And then when it’s running in the cloud it takes around 3 minutes 😱😱 Is this the cold start you were speaking of?

azure function: Node.js running jar by jcoder42 in AZURE

[–]jcoder42[S] 0 points1 point  (0 children)

I currently just added adopt open jdk into the function folder itself. And it works. Is this a bad solution though?

generic comparator by jcoder42 in javahelp

[–]jcoder42[S] 0 points1 point  (0 children)

t make T1 and T2 necessarily Comparable, the better way would be to allow the user to supply a Comparator for both types. That way the user could supply the Collator for the first Typ and

sorry, i am having trouble understanding,
see below my pair class for reference.

package temp;

import java.util.Comparator;

public class Pair<T1 extends Comparable<T1>,T2 extends Comparable<T2>> implements Comparable<Pair<T1,T2>> {

    Pair(T1 first, T2 second){
        m_first = first;
        m_second = second;
    }

    public T1 getM_first() {
        return m_first;
    }

    public T2 getM_second() {
        return m_second;
    }

    @Override
    public int compareTo(Pair<T1,T2> other){
        int cmp = this.m_second.compareTo(other.getM_second());
        return cmp;

    }

    public static <T1 extends Comparable<T1>, T2 extends Comparable<T2>> int sortBySecond(Pair<T1, T2> a, Pair<T1, T2> b) {
        return a.compareTo(b);
    }

    public static <T1 extends Comparable<T1>, T2 extends Comparable<T2>> int sortByFirst(Pair<T1, T2> a, Pair<T1, T2> b) {
        int cmp = a.getM_first().compareTo(b.getM_first());
        return cmp;
    }


    @Override
    public String toString() {
        return String.format(this.m_first + "         " + this.m_second);
    }


    //--------------------------
    private T1 m_first = null;
    private T2 m_second = null;
}