Create WebFile with ZipFile

Hi, I have some issue about WebFile on my web application, I already had zip file on my linux server then I would like to made it for download, So I plan to use URL on WebFile. I created WebFile with this code and then “ShowUrl” to get url or link to file, But the problem is when download was finish I cannot unzip my file it show error “(Error 1 - Operation not permitted)” and I can confirm that the original file are good. Please give me some suggestion for solve this problems

s, is folderitem which reach to path zipfile

		Dim f1 As FolderItem = GetFolderItem(s.NativePath, FolderItem.PathTypeNative) 
		If f1 <> Nil And f1.Exists Then
				App.zipFile = New WebFile
				App.zipfile.ForceDownload = True
				App.zipFile = WebFile.Open(f1)
		End If
ShowURL(App.zipfile.URL)

The open function replaces your object.
So you don’t need the new Webfile line and set the download flag after Open

[quote=330007:@Christian Schmitz]The open function replaces your object.
So you don’t need the new Webfile line and set the download flag after Open[/quote]

Hi, Christian Schmitz
thanks, for your advice, I try with this code, but still on luck my downloaded file still occur same error

		Dim f1 As FolderItem = GetFolderItem(s.NativePath, FolderItem.PathTypeNative)
		If f1 <> Nil And f1.Exists Then
				App.zipFile = WebFile.Open(f1)
				App.zipfile.ForceDownload = True
		End If

App.zipFile = WebFile.Open(f1) App.zipfile.ForceDownload = True ShowURL(App.zipfile.URL)

this should be enough and work. No errors?

[quote=330013:@Christian Schmitz]App.zipFile = WebFile.Open(f1) App.zipfile.ForceDownload = True ShowURL(App.zipfile.URL)

this should be enough and work. No errors?[/quote]

Yep, I already try that one but the downloaded file still cannot unzip, Have any way to check my WebFile(App.xipFile) is correct type of file?
My Xojo version is 2016 R4.1

http://documentation.xojo.com/index.php/WebFile.MIMEType

[quote=330019:@Michel Bujardet]http://documentation.xojo.com/index.php/WebFile.MIMEType
http://www.freeformatter.com/mime-types-list.html[/quote]

Hi Michel, I try with your suggestion
Here my code

				App.zipFile = WebFile.Open(f1)
				App.zipFile.MIMEType = "application/zip"
				App.zipfile.ForceDownload = True
				ShowURL(App.zipfile.URL)

But the downloaded file still had error when unzip, I try to debug the WebFile’s properties, MIMEType are “application/zip” already

How big is your zip file ? Over 50 Megs, Webfile cannot deal.

If your app is not standalone, better place the file in the web space and download directly.

[quote=330149:@Michel Bujardet]How big is your zip file ? Over 50 Megs, Webfile cannot deal.

If your app is not standalone, better place the file in the web space and download directly.[/quote]

Hi Michel, Thank you for your suggestion, My zip file is lower than 1mb.
Finally, I found the solution From code above I change the path type to “PathTypeShell” and that’s worked!! (On Ubuntu server)

				Dim f1 As FolderItem = GetFolderItem(zipPath.NativePath, FolderItem.PathTypeShell)
				If f1 <> Nil And f1.Exists Then
						App.zipFile = WebFile.Open(f1)
						App.zipFile.MIMEType = "application/zip"
						App.zipfile.ForceDownload = True
						ShowURL(App.zipfile.URL)
				End If

I don’t know why PathTypeNative not working but I can use this on my Linux server, Thanks guy for help and advice useful information to me

The difference between native and shell is that shell is escaped. We could not help you with that, since AFAIK you did not post that path.

Glad to know it works.

why do you need to get a path from folder item to just create a new folder item from that path.
That sounds crazy!