Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to upload file to Azure file storage

Status
Not open for further replies.

TinyNinja

Programmer
Oct 1, 2018
99
US
Hey everyone,

I have an app with a user form that will allow the user to scan a document, save it locally and now trying to upload it to Azure File Storage. There is a folder structure on the cloud and I want the file to upload to a certain spot. The file will either be a JPG or PDF that will need to be uploaded. Does anyone have any insight?

I was playing with the idea of using FTP and could not get that to work.
 
Thanks for the response.

I've never used those options before. Are they able to easily integrate into a vfp form?
 
These are not native VFP options. They are rather small executive files which can be called externally from VFP. Please search for pstools.
 
Nigel said:
a simple REST API that could be implemented using any HTTP components

I also see it that way.

Overview: Set File Rest API documentation:
You need to dig into the details of the request structure, but in the end the Set File Set method is a PUT http request.

If you want to use CURL specifically tailoredfor VFP usage and not just as command line tool, there is a LIBCURL from Carlos Alloatti:

But if it's new to you, you can also put together a HTTP request without any library with what Windowss has on board already, like WinHttp.WinHttpRequest or Windows API Wininet.DLL functions and West Winds' wrapper wwIPStuff.

Bye, Olaf.

Olaf Doschke Software Engineering
 
I'm good with using an external exe file to get the job done.

I will look into pstools. I did some across Chilkat solutions and will look into nsoftware.

Thank you for all the help!
 
Hey Olaf,

Thank you for your leads. I was hoping to find something like this so I can keep the expense of the application to a minimum.
I am going to read into your links more and figure which ways Azure likes to be interacted with.
 
TinyNinja,

appreciate the need to keep costs to a minimum but, FWIW, i have found chilkat to be money well spent.

n
 
Couldn't you just map a drive to the Azure File Share and save as before to this new mapped drive?
I have not tried this but it seems like you should be able to do it.

Ed
 
Nigel - I agree with you too and see if I can get chilkat to work. I'm just not paying for these functions so keeping the price low is best for the person I am making this for.

Ed - You are correct, it is possible to make it a mapped drive. The problem is this application will be sitting on 10 plus different computers in different parts of the state I live in and all need to be able to upload to Azure file storage. It would make my life easier to have the code handle the transfers instead of me setting up a mapped drive on every PC.
 
Yeah that might be a pain.
You could use a PowerShell script to do the heavy lifting of mapping the drive but would need to make sure port 445 is open.

Anyway - keep us posted.
Ed

Ed
 
It really is Ed.

I went with the Chilkat option and using Azure File Service Upload File & Upload Large File.

Since I do not know the file size of the scanned documents I am using a If statement to catch if the file is bigger than 4mb than chop up the file and send it in chunks ELSE just send the file as is.

I've tested it out with my scanner and it works great.

I'm not sure if anyone wants to see the code since I followed Chilkat example exactly and it worked.
 
I don't think you need chunking, but it can't hurt, the use case might not stay with scans. I just wonder why you cut in 4mb chunks. Is it a service restriction? Did you get status 413 or 500? The VFP limit is 16MB for strings. Some things still work with larger strings. Variables store just about 32MB.

Chilkat component is an ActiveX, isn't it? Is the limit coming from there?

Or is it also simple a practical limit you set yourself? It could become really uncomfortable in a network if large requests fail and are repeated until they work, of course.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Hey Olaf,

Chilkat has a limit of 4mb on their upload example. They state Azure has a 4mb limit.

I tested out Chilkat normal file upload with a 7mb file and it failed. I then used the chunking method and it worked like a charm.
I agree it would be bad if files fail. I believe the end user will only be scanning a few documents a week to the cloud storage so I think this won't be an issue.
 
Thanks for clearing that up. It's a sensible limitation. In case you don't even get notified and the HTTP or TCP/IP protocol automatically repeat failed packets, one too large file could end clogging the network by going to the cap number of retries or timeout. Makes double sense, therefore.

Bye, Olaf.

Olaf Doschke Software Engineering
 
You're welcome :)

I have one last question.

Everything works on my PC. I compiled it into an EXE with all the needed Dll's. I also threw the Chilkat dll file into the same folder and now am testing on an extra PC. The code cannot find the Chilkat info and fails.

How would I point the code to the Chilkat Dll in the same folder to make it work on another computer?
 
It's an ActiveX DLL with OLE classes that VFP only finds when they are registered. So the easiest should be to run the Chilkat setup. It should come with redistribution permissions, or else you'd had a hard time using it on more than your development computer. And it may have an easy option for silent install, I don't know.

I'd definitely ask Chilkat or refer to their readme/manual, especially as you already told us you do this to spare some extra effort like a drive mapping. And I assume that's because it needs administrative permissions. You now need them to register the OLE classes.

There are usually four ways to register and three of them need administrative permissions: 1. by setup, 2. by self-registration (needs the whole process to run elevated at least once, though), 3. running regsvr32, (elevated of course), and 4. Reg free COM by a manifest you embed in your EXE (needs no admin permissions). This effectively embeds the information where to find the OLE classes in your EXE.

The latter could come to your rescue and would require you to put a manifest file with certain content into the project folder, so the VFP build embeds that in your EXE.

Before you Just one warning beforehand: Before you jump into the details of and try to figure your way into what infos you need specifically for the family of Chilkat OLE classes, ask them, ask Chilkat. They may even be able to provide such a manifest definition, so you don't have to work that out, just merge it into Foxpros' own, and you find that described here:


Bye, Olaf.

Olaf Doschke Software Engineering
 
Olaf,

Thank you for the detailed options I have. I found that Chilkat ActiveX has a register_win32.bat file.
I will see if I can get this to run on the first time the program is started by a new user. Hopefully that can solve my problem and if not then I will try your other options suggested.
I will also read more about manifests and how to use those.
 
Fine. Manifests are a huge topic, don't drown in it, it's not only about regfree COM, your EXE can for example also declare to be dpiaware and for Foxpro applications that can get rid of blurry scaling of controls and images when Windows font scaling is in use. And that's just one more example of what you can define there.

For sake of use of such a bat file, its properties should include the option to run them as admin. But then that only is silent when the user is admin/in the local admin group. If not you get the elevation prompt.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top