×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to upload file to Azure file storage

How to upload file to Azure file storage

How to upload file to Azure file storage

(OP)
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.

RE: How to upload file to Azure file storage

curl or pscp can do that.

RE: How to upload file to Azure file storage

(OP)
Thanks for the response.

I've never used those options before. Are they able to easily integrate into a vfp form?

RE: How to upload file to Azure file storage

These are not native VFP options. They are rather small executive files which can be called externally from VFP. Please search for pstools.

RE: How to upload file to Azure file storage

Quote (Nigel)

a simple REST API that could be implemented using any HTTP components

I also see it that way.

Overview: https://docs.microsoft.com/en-us/rest/api/storages...
Set File Rest API documentation: https://docs.microsoft.com/en-us/rest/api/storages...

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:
https://github.com/calloatti/LIBCURL

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
https://www.doschke.name

RE: How to upload file to Azure file storage

(OP)
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!

RE: How to upload file to Azure file storage

(OP)
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.

RE: How to upload file to Azure file storage

TinyNinja,

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

n

RE: How to upload file to Azure file storage

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

RE: How to upload file to Azure file storage

(OP)
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.

RE: How to upload file to Azure file storage

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

RE: How to upload file to Azure file storage

(OP)
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.

RE: How to upload file to Azure file storage

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
https://www.doschke.name

RE: How to upload file to Azure file storage

(OP)
Hey Olaf,

Chilkat has a limit of 4mb on their upload example. They state Azure has a 4mb limit.
https://www.example-code.com/foxpro/azure_file_ser...

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.

RE: How to upload file to Azure file storage

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
https://www.doschke.name

RE: How to upload file to Azure file storage

(OP)
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?

RE: How to upload file to Azure file storage

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 https://west-wind.com/wconnect/weblog/ShowEntry.bl... 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:

https://west-wind.com/wconnect/weblog/ShowEntry.bl...

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: How to upload file to Azure file storage

(OP)
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.

RE: How to upload file to Azure file storage

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
https://www.doschke.name

RE: How to upload file to Azure file storage

(OP)
That's useful information Olaf.

Hey Mjcmkrsr,
I do not want my users to have to manually upload files to Azure cloud. That will be a pain and the user will get it wrong. I just need the code to do it automatically.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close