I used long polling API to keep track changes in Box users files, when user rename file return the new name only.
Is there any way to get the old file name before rename?
If you have a file id, you can use the View Versions endpoint to get information about old versions of the file including previous file names.
Related
I have a requirement of finding the recently modified/created file from a directory and rename it to a standard name run that file and then rename it back to previous name. How can this be achieved?
Steps needed to be achieved:
finding the recently modified/created file
rename that file to a standard name.
run that file
rename it back to previous name.
I used a script task to find the recent file, but i could not move forward. I tried many things. Any solution on how to implement this?
I used this blog to find the recently modified/created file - https://www.techbrothersit.com/2013/12/ssis-how-to-get-most-recent-file-from.html
How can I save two files with the same file name in the same folder without renaming anyone using php?
For instance: A user has an audio file name "first.mp3"; and another user uploads another file named: "first.mp3"; and I want to save these two files without renaming any so that when people are downloading the audio from the front end, the name does not change.
I can do this by concatenating a random number to differentiate the files but I want to beat this method of renaming.
Should I be saving each file inside a unique folder and save the file names to database? but this method will create too many folders which i don't think it is appropriate.
You cannot have two files with the same name in the same folder.
You would either have to add a random string to the end of each file like you suggest or save each user's files in a directory allocated to their account.
Regards,
Leslie
Saving multiple files with the same name within the same folder is just not possible.
I'd opt for a strategy that would involve saving the original filename somewhere (in a database, for example) along with the name/path of the actual file. When the User downloads the file (presumably through a web app of some sorts), you can set the name of the file via headers with your language of choice.
You could even rename the files to something completely random when they're uploaded so you can have them all in one folder - as long as you store the original filename somewhere, you can always set it before you serve it back to the end user.
I have a google drive directory with many files. In theory I could access them and cross-link them via
https://developers.google.com/drive/v2/reference/files/watch
or just using an URL with this identifier. The key issue is, how can I export the identifiers for the files in a google directory, doing this manually is not an option.
source:
https://developers.google.com/drive/v2/reference/
Export? I'm not sure I entirely understand what you mean by that, but I'm guessing you want a list of all the file IDs in a certain directory.
This is a simple case of using the files.list request. For 'q' you would want to do '<folderID>' in parents and for fields you would do items/id,nextPageToken (for efficiency). items/id gets you the file ID and nextPageToken is used to resend the list request to get the next set of IDs in the event it requires more than 1 page of results.
So, as an example, let's assume the folder you want is your root folder 'My Drive'. In that case, the following would be the query:
GET https://www.googleapis.com/drive/v2/files?q='root'+in+parents&fields=items%2Fid%2CnextPageToken&key={YOUR_API_KEY}
and if nextPageToken comes back with something, you would subsequently do:
GET https://www.googleapis.com/drive/v2/files?pageToken={YOUR_PAGE_TOKEN}&q='root'+in+parents&fields=items%2Fid%2CnextPageToken&key={YOUR_API_KEY}
I am new to the infusionsoft API and I am attempting to maintain some files in a Contacts' File Box...
According to the API documentation:
https://developer.infusionsoft.com/docs/read/File_Service
I can ADD a file
I can RENAME a file
I can REPLACE a file
There appears to be no way of deleting a file or getting a list of files with their details..
I want to be able to replace or delete previous file and upload a new one.
Does anyone know a way of doing this?
Thanks
Welcome to the wonderful world of the data service and interacting with tables! Specifically, you're going to want to use DataService.delete to delete the file in the database. You can also use DataService.query to get File details.
Here's an example for deleting a file, via the PHP SDK:
$file_id = 123;
$deleted = $app->dsDelete( 'FileBox', $file_id );
That's it! You can do a LOT with the Data Service.
EDIT: It looks like the FileBox table only allows Read access...Silly. Completely deleting the file via the API appears to be impossible. Gold Star, InfusionSoft.
An alternative for "deleting" a file would be to replace the file contents with an empty string. Something like:
$file_id = 123;
$deleted = $app->replaceFile( $file_id, '');
Note that this won't actually delete the file entry from the table...
There isn't a way of deleting files from the FileBox via the API. This was done intentionally to prevent files from accidentally being deleted.
I have a CGI program I have written using Perl. One of its functions is to upload pics to the server.
All of it is working well, including adding all kinds of info to a MySQL db. My question is: How can I get the uploaded pic files location and names added to the db?
I would rather that instead of changing the script to actually upload the pics to the db. I have heard horror stories of uploading binary files to databases.
Since I am new to all of this, I am at a loss. Have tried doing some research and web searches for 3 weeks now with no luck. Any suggestions or answers would be greatly appreciated. I would really hate to have to manually add all the locations/names to the db.
I am using: a Perl CGI script, MySQL db, Linux server and the files are being uploaded to the server. I AM NOT looking to add the actual files to the db. Just their location(s).
It sounds like you have your method complete where you take the upload, make it a string and toss it unto mysql similar to reading file in as a string. However since your given a filehandle versus a filename to read by CGI. You are wondering where that file actually is.
If your using CGI.pm, the upload, uploadInfo, the param for the upload, and upload private files will help you deal with the upload file sources. Where they are stashed after the remote client and the CGI are done isn't permanent usually and a minimum is volatile.
You've got a bunch of uploaded files that need to be added to the db? Should be trivial to dash off a one-off script to loop through all the files and insert the details into the DB. If they're all in one spot, then a simple opendir()/readdir() type loop would catch them all, otherwise you can make a list of file paths to loop over and loop over that.
If you've talking about recording new uploads in the server, then it would be something along these lines:
user uploads file to server
script extracts any wanted/needed info from the file (name, size, mime-type, checksums, etc...)
start database transaction
insert file info into database
retrieve ID of new record
move uploaded file to final resting place, using the ID as its filename
if everything goes file, commit the transaction
Using the ID as the filename solves the worries of filename collisions and new uploads overwriting previous ones. And if you store the uploads somewhere outside of the site's webroot, then the only access to the files will be via your scripts, providing you with complete control over downloads.