How to append data to existing Dropbox file? - java

I'm accessing Dropbox API to upload and download files using Java. Now, I need to create a function which can append data to existing Dropbox file.
I've a working code which first downloads a file and then uploads it with the text appended. However, is there is a better way to do this, because my code has is inefficient?
Thanks in advance. :)

Conventionally there is no support for direct file editing in Dropbox, so what you looking for is not supported in existing APIs of Dropbox, possibly what you are doing currently,
first downloads a file and then uploads it with the text appended
is the best (and the only) way of modifying files in Dropbox cloud.
But apart from this it does support file revision mechanism, which can be achieved with help of /delta, /revision
A way of letting you keep up with changes to files and folders in a
user's Dropbox. You can periodically call /delta to get a list of
"delta entries", which are instructions on how to update your local
state to match the server's state.
https://www.dropbox.com/developers-v1/core/docs#revisions
Best Luck :)

Related

How to read txt file from Google Drive?

I'm trying to make launcher for my game. I want it to display update log. How I want it to work:
Replace log.txt file on Google Drive and new log will be displayed in launcher.
I have no idea how to make this. Also I have to make auto-updater.
It will work similiar to update log - upload .jar file and res folder on drive. When game launched it will check for updates and if new update available it will download it.
Like I said, I have no idea how to do this.
I advise you to use GitHub to upload your files. Then you can use the URL provided by GitHub to open a urlStream in your project and read that file like a .txt.
Google drive is a file explorer only. It will allow you to upload and download files, it does not have the power to display or edit them. Unless you want to display them in the Google drive web application in which case there should be a webContentLink available in the response data for the file.get method, however the file will need to be either public or the user must have access to it in order to be able to see it.
To display the file you will need to download it and display it locally. To edit it you will need to download the file and edit it then upload it again.
Tbh i think what you are asking is out of scope for this api.

Azure Functions and temporary File Storage

I'm a beginner and have never dealt with cloud-based solutions yet before, so apologies for the dumb question.
I have an Azure Blob Storage containing PDF files from which I want to extract data using PDFBox. Because PDFbox can't load blobs directly, I currently download these files locally first. However, eventually my project will need to become fully Cloud-based, preferably as an Azure Function.
The main hurdle therefore is figuring out how my Azure Function should access the files. When using the console inside my Azure Function I noticed it comes with a file storage. Can the Function download blobs and store them here before processing it? Does this file storage work the same as a local environment or are there differences to keep in mind?
I'm only looking to store files temporarily here, for only a few minutes at a time.
The main hurdle therefore is figuring out how my Azure Function should
access the files. When using the console inside my Azure Function I
noticed it comes with a file storage.
Yes, all of the information of your deployed azure function is stored in the file storage you set.(It is defined when you create the function app.)
Can the Function download blobs and store them here before processing
it? Does this file storage work the same as a local environment or are
there differences to keep in mind?
Yes, you can. And the root directory is D:/home/site/wwwroot. So if you don't specify, the file you create will be in this directory.
Remember to delete the files, because the storage space is limited. It is based on the plan you selected.
I'm only looking to store files temporarily here, for only a few
minutes at a time.
By the way, if you get a file from blob storage, at this time you have completely got its data. You can process the obtained data directly in the code without temporarily storing it in the current folder. (Of course, if you have special needs, please ignore this one.)
You can use a blob trigger or input binding to load a blob into memory of your function for processing by PDFBox.
With regards to the local file system, you can read about more about it here. From the description of your problem I think a blob trigger or input binding should be sufficient for you.

How to display directory in Spring App?

So I'm writing a Spring web application that runs some scripts on the local server using ProcessBuilder. That part seems to be running fine. The scripts generate output files and then zip them up into a single .zip file. I'd like to provide the user with a way to download these files but I'm not sure of the best way to do this, or even how to implement any way to do it.
I tried putting the path to the directory into the URL, but I believe since Spring intercepts all URLs and it doesn't know how to process the one pointing at either the directory the Zip is in or the Zip itself, I just get an error. What would the proper way to do this be? Either to display a list of files or just link to the files themselves? Any help would be really appreciated, thank you.
The way you do any file download from a web-app is to write a servlet that writes the content of the file to the http response's output stream. There's an example of this here that's downloading an Excel file.
The directory listings that you get in a web-page don't just happen automatically, you'll have to write a JSP that displays the directory listing with hyperlinks on each file that link to file download servlet.
I looked around and could not find a complete directory listing example for spring. Though it is relatively simple to implement I put together a blog post to explain this, so that it could be quickly reused when needed http://krishna-passionatelycurious.blogspot.com/2013/04/file-download-page-using-spring.html.
But, the overall approach is to loop through the contents of a directory and generate appropriate links, such that the links point back to the same spring handler, where we could make a decision based on whether the accessed link actually points to a directory or a file and generate directory listing again or stream the content for download.
The blog has a sample implementation of this.

Downloading and storing files with checksum information in Java

We are building a service to front fetching remote static files to our android app. The service will give a readout of the current md5 checksum of a file. The concept is that we retain the static file on the device until the checksum changes. When the file changes, the service will return a different checksum and this is the trigger for the device to download the file again.
I was thinking of just laying the downloaded files down in the file system with a .md5 file next to each one. When the code starts up, I'd go over all the files and make a map of file_name (known to be unique) to checksum. Then on requests for a file I'd check the remote service (whose response would only be checked every few minutes) and compare the result against that in the map.
The more I thought about this, the more I thought someone must have already done it. So before I put time into this I was wondering if there was a project out there doing this. I did some searching but could not find any.
Yes, it's built into HTTP. You can use conditional requests and cache files based on ETags, Last-Modified, etc. If you are looking for a library that implements your particular caching scheme, it's a bit unlikely that one exists. Write one and share it on GitHub :)

Resaving A Blob File In Java

I have a web application in GWT and a complementary desktop client also written in Java (so the same solution basically applies to both). In my program users can attach files, then download them later or do whatever. These files are stored as blobs and can be in just about any format. Many of the users that use Excel and Word want to be able to open the file, make changes, then have those changes stored back in the attached file. In other words, need an inline editing of attachments.
Any ideas on how to make this happen? Should I have an 'edit' mode that keeps a file handler while the file is open, and then store that File handler? Some way keeping track of whether the file is changing, or not?
Sorry about the late response. Amol >> I have that going. I want to save directly back to a blob as if it were a filehandle. Thought that was clear in my question.
I have decided that this is almost impossible with a web application without writing some kind of client interface for each and every potential file type - word, excel, pdf, graphics, etc...

Categories