cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
dadawasozo
Level IV

open and download few files from a zip folder through JFrog artifactory http link

Hi,

 

I want to read few files from zip folder through JFrog artifactory http link. I 'm not quite sure how I can solve the issue below:
1) user and password needed when access the link

2) the script I used could have issue that it gave me error

 

The link I try to access looks like below ( created a fake one to show how it looks like )
http://docker-virtual.artifactory.xxx.com:80/ui/repos/tree/General/Sxxxx/logs/ABC/1111_23456_1_test....

 

below is a draft of script I put together but it doesnt work. I was told I can create API key that can be used to bypass the user and password for sign in but not able to make it work. Can someone help me out here? 

 

request = NewHTTPRequest(
	URL( "http://http://docker-virtual.artifactory.xxx.com:80/ui/repos/tree/General/Sxxxx/logs/ABC/1111_23456_1_test.zip" ),
	Method( "GET" ),
	);
zip = request << Send;

za=open(zip,"zip");
zipfiles=za<<dir;
for (l=1, l<=N Items(zipfiles), l++,
If (
	zipfiles[l]== "somelog.log" ,
	text=za<<read(zipfiles[l]);
	save text file(path1|| todaydate || "log1",text)
	)
	)

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: open and download few files from a zip folder through JFrog artifactory http link

YouTube API  shows one way an api key might work. Did the documentation they supplied tell you how to supply the one you received?

Craige

View solution in original post

9 REPLIES 9
Craige_Hales
Super User

Re: open and download few files from a zip folder through JFrog artifactory http link

YouTube API  shows one way an api key might work. Did the documentation they supplied tell you how to supply the one you received?

Craige
dadawasozo
Level IV

Re: open and download few files from a zip folder through JFrog artifactory http link

 

To deploy the file using API Key in a header, you would use the following command:

curl -H "X-JFrog-Art-Api:ABcdEF" -X PUT "http://localhost:8081/artifactory/my-repository/my/new/artifact/directory/file.txt" -T Desktop/myNewFile.txt

 

dadawasozo
Level IV

Re: open and download few files from a zip folder through JFrog artifactory http link

Craige,

 

1) Can we still using the open() to open zip folder and download specific file through webpage?
2) Can we open and read one of the file in the zip folder through page and get only some text out of it?

Craige_Hales
Super User

Re: open and download few files from a zip folder through JFrog artifactory http link

Curl's -H specifies a header, which requires you to use New HTTP Request. open() can add a query string but can't add headers, so it won't do what you need.

help->scripting indexhelp->scripting index

I think you'll need

headers({"X-JFrog-Art-Api:ABcdEF"})

but not the query string and fields.

Once you get the zip file, you can use JMP's zip archive support to get the unzipped members.

 

You might use download rather than send:

download a filedownload a file

@bryan_boone 

 

Craige
Craige_Hales
Super User

Re: open and download few files from a zip folder through JFrog artifactory http link

Also, your example is a PUT, not a GET. You probably picked up the PUT example from part of the doc that puts new data into the database. There is probably a GET example for getting old data from the database. GET and PUT are part of the way a REST-ful server works, and there are other verbs too.

Craige
dadawasozo
Level IV

Re: open and download few files from a zip folder through JFrog artifactory http link

If I use the download, will it download the whole zip? I dont want the whole zip file because it is huge. I want to open the zip folder and just get the files I wanted.

Craige_Hales
Super User

Re: open and download few files from a zip folder through JFrog artifactory http link

Yes, it downloads the whole zip file, not a member. Unless the API has a method to get the smaller chunk, you'll need to get it all and only unzip what you need. Many APIs allow for what you are trying to do by making a custom zip file of just the items you want. You might have to do some reading in the API doc to puzzle it out.

Craige
dadawasozo
Level IV

Re: open and download few files from a zip folder through JFrog artifactory http link

not success. I found that there are 2 options for using api key for authentication and download file from artifactory:
1) curl -uadmin:API-Key -ocommons-collections-3.1.jar http://localhost:8081/artifactory/jcenter/apache-collections/commons-collections/3.1/commons-collect...

2) curl -H "X-JFrog-Art-Api: API-Key" -ocommons-collections-3.1.jar http://localhost:8081/artifactory/jcenter/apache-collections/commons-collections/3.1/commons-collect...

 

I tried the 2) in script below because of the use of header, but it didnt download the file, but some strange character which I posted at below. I 'm not sure where it went wrong. 

temp.log file with information below instead of the content from the url
<!doctype html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><meta name=importmap-type content=systemjs-importmap><link rel=apple-touch-icon sizes=180x180 href=./apple-touch-icon.png><link rel=icon type=image/png sizes=32x32 href=./favicon-32x32.png><link rel=icon type=image/png sizes=16x16 href=./favicon-16x16.png><link rel=mask-icon href=./safari-pinned-tab.svg color=#f5f5f2><link rel="shortcut icon" href=./favicon.ico><link rel=stylesheet type=text/css href=/ui/webapp/css/vendorStyles.css><link rel=stylesheet type=text/css href=/ui/webapp/css/application.css><script type=systemjs-importmap src=/ui/imports-map/imports.json></script><script src=/ui/externals/import-map-overrides/dist/import-map-overrides.js></script><script src=/ui/externals/systemjs/dist/s.min.js></script><script src=/ui/externals/systemjs/dist/extras/amd.min.js></script><script src=/ui/externals/systemjs/dist/extras/named-exports.min.js></script><link rel=preload href=/ui/externals/vue/dist/vue.min.js as=script><link rel=preload href=/ui/externals/vue-router/dist/vue-router.min.js as=script><link rel=preload href=/ui/externals/jfrog-ui-essentials/dist/jfrog-ui-essentials.umd.min.js as=script><link rel=preload href=/ui/externals/single-spa/lib/umd/single-spa.min.js as=script><base href=/ui/ ><title>JFrog</title><style>@keyframes heartbeatOut{from{opacity:1}50%{opacity:0;transform:scale(.8)}to{opacity:0;transform:scale(.8)}}@keyframes heartbeat{from{transform:scale3d(1,1,1)}50%{transform:scale3d(1.15,1.15,1.15)}to{transform:scale3d(1,1,1)}}.pounding-heart-container{display:none;align-items:center;justify-content:center;position:absolute;left:0;right:0;top:0;bottom:0;z-index:9999999999;background:linear-gradient(132.49deg,#414857 14.17%,#252831 83.36%)}.pounding-heart-container.show-splash{display:flex}.logo{width:130px;-webkit-backface-visibility:hidden;-ms-transform:translateZ(0);-webkit-transform:translateZ(0);transform:translateZ(0)}.logo.pulse{animation:heartbeat 1.7s infinite}.logo.zoom-out{animation:heartbeatOut 150ms forwards}</style><link href=/ui/css/app.4de23844.css rel=preload as=style><link href=/ui/css/chunk-vendors.cee239a1.css rel=preload as=style><link href=/ui/js/app.3b20d340.js rel=preload as=script><link href=/ui/js/chunk-vendors.61f2dc48.js rel=preload as=script><link href=/ui/js/preloader.31ea7863.js rel=preload as=script><link href=/ui/css/chunk-vendors.cee239a1.css rel=stylesheet><link href=/ui/css/app.4de23844.css rel=stylesheet></head><body><div class="pounding-heart-container show-splash"><img class="logo pulse" src=/ui/img/jfrog.8f770bff.svg></div><noscript><strong>We're sorry but jfrog webapp doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/ui/js/chunk-vendors.61f2dc48.js></script><script src=/ui/js/app.3b20d340.js></script><script src=/ui/js/preloader.31ea7863.js></script></body></html>

request = NewHTTPRequest(
	URL( "http://http://docker-virtual.artifactory.xxx.com:80/ui/repos/tree/General/Sxxxx/logs/ABC/1111_23456_1_test.zip/test.log" ),
	Method( "GET" ),
        headers({"X-JFrog-Art-Api: API-Key"})
	);
zip = request << download("D:\temp.log", "replace", "show_progress");

 

dadawasozo
Level IV

Re: open and download few files from a zip folder through JFrog artifactory http link

Hi Craige,

 

I found the issue and get it fixed. The problem is from the URL. replacing "ui/repos/tree/General" with "artifactory" and then I able to download the whole zip file, not the specific file.

Thanks for your help