Pivotal Cloud Foundry Support

 View Only

 HI in my project we have a requirement to read the file from Unix box in PCF GAIA. we were using FTP in legacy code and code is being migrated to PCF. is it possible in PCF environment?

sam s's profile image
sam s posted Apr 28, 2019 01:33 PM


Daniel Mikusa's profile image
Daniel Mikusa

If you need files to be available to your application when it's running, you have a couple options:

  • Include them with the application when you run `cf push`. This will ensure that the files are bundled into the droplet that is produced and they will be available to all application instances.
  • Create a custom buildpack that installs the files during stagign. Again, this will ensure that the files are bundled into the droplet that is produced and will ensure that the files are available to all application instances.
  • You could use `scp` or `sftp`. The cf cli does not natively support these, but you can use the standard `scp`, `sftp` (or anything that supports those, like `rsync`) to add files to an app instance. Note that this will only add them to one app instance, not all app instances. If your app has multiple instances, you would need to upload the files to each one individually. In addition, the files will only exist until an app instance is restarted. Because the local file system is ephemeral, anything written there is lost after the app instance restarts. A restart could come from calling `cf restart`, an app instance crash or even due to platform maintenance & upgrades. If you were uploading files, processing them and deleting them this option could work OK. If you are uploading assets like images, you would not want to do this.
  • You can use shared storage. Using Volume Services, you can mount external storage over NFS or SMB into your application container. You could then modify files on the external storage and changes should reflect immediately in your app. This would probably be the best option if you're trying to manage assets like images for an application.
  • You could build functionality into the application to allow the upload of files. This would be very similar to the `cf ssh` option, but would be decoupled from the platform itself and would run over HTTP/HTTPS. It has the same file system limitations, in that anything you write to the local file system will not survive a restart. It also has the same limitations in that you're talking to one specific app instance. It would also be a good solution if you're trying to upload files which are processed and deleted. It would not be good if you're trying to upload assets which need to be retained for a long period of time.


Hope that helps!