I want to iterate putting different files to a server

Hi,

I am new to postman.

I want to test downloading various size files, (between 5 & 20MB) to a server. Can this be done via a Pre-request test script populating the files to be downloaded. Was hoping to set up a local URL for each file to be downloaded?

Was wondering if I could create a pre-request test script to populate the filenames somehow so that I could iterate on the test script?

Thanks.

–Jim

From your question is a bit unclear what the problem is.

Can you please share what you have tried so far, where are you getting the list of files to be downloaded.

@jamesp.hurl

vdespa asks a good question, but I’ll take a guess at what your asking.

You could create a JSON file called … downloadFile.json … in the file you would put this …

[
{"fileURL": "http://somedomain.com/testfiles/5megFile.whatever"},
{"fileURL": "http://somedomain.com/testfiles/10megFile.whatever"},
{"fileURL": "http://somedomain.com/testfiles/15megFile.whatever"},
{"fileURL": "http://somedomain.com/testfiles/20megFile.whatever"}
]

If you run the test in the Collection Runner, you would select this JSON file as input and after selecting it, the iteration count should reflect the amount of lines in the file … in this case … 4.

When you run the test, it will iterate 4 times, each time reading each line in succession. You will then have access to the urls …

In the pre-req script …

pm.iterationData.get("fileURL") 

or as {{variable}} in a request body …

{
    "fileToDownload" : "{{fileURL}}"
}

or directly in-line in the endpoint …

http://someAPIserver.com/downfile/{{fileURL}}

It all depends upon how you have implemented the download in your endpoint.

Hope this helps.

What I have done is place the file I need to download in an env file, along with other variables I need set. For example:

ENV file:

{
“id”: “f63730ed-92e7-f8a8-fb8b-005993bd5197”,
“name”: “local”,
“values”: [
{
“enabled”: true,
“key”: “server”,
“value”: “https://192.168.77.158:443”,
“type”: “text”
},
{
“enabled”: true,
“key”: “version”,
“value”: “1”,
“type”: “text”
},
{
“enabled”: true,
“key”: “file_to_upload_env”,
“value”: “CSdev.apk”,
“type”: “text”
},
{
“enabled”: true,
“key”: “application_id_ref_env”,
“value”: “8870087b359399d6f22a249e7c6342f5”,
“type”: “text”
},
{
“enabled”: true,
“key”: “platform_type_env”,
“value”: “android”,
“type”: “text”
}
],
“timestamp”: 1519766311494,
“_postman_variable_scope”: “environment”,
“_postman_exported_at”: “2018-03-01T20:37:16.339Z”,
“_postman_exported_using”: “Postman/5.5.2”
}

I then exported my Collection from Postman. In the exported JSON file I substitute the “*_env” files above into the JSON (i.e. . This then allows me to run the collection from Newman. The only negative is I need an env file for each file I am operating on, so I wrap the Newman CLI with a shell script that invokes each env file.

In the collection file for example:

					"method": "POST",
					"header": [],
					"body": {
						"mode": "formdata",
						"formdata": [
							{
								"key": "app",
								"src": "{{file_to_upload_env}}",
								"description": "IPA / APK / Other",
								"type": "file"
							}
						]
					},

If I could iterate I would not need to have multiple environment files.

I like the URL solution. I will try & get this to work. For each file there are other params which
go along with the file, so I will need to iterate over a group of attributes for a given file.

Will let you know how I make out.

Appreciate the feedback & possible solution.