Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify File field model #102

Closed
Arithmomaniac opened this issue Jun 11, 2018 · 2 comments
Closed

Simplify File field model #102

Arithmomaniac opened this issue Jun 11, 2018 · 2 comments

Comments

@Arithmomaniac
Copy link
Collaborator

Currently, file fields expose RSAPI's FileMetadata and FileValue classes directly. These contain far more information than we need.

We should map to/from a custom object with the following three fields:

  • byte[] data
  • string FileName (can be inferred if FilePath is supplied)
  • string FilePath (left blank on server reads)
@Arithmomaniac
Copy link
Collaborator Author

Arithmomaniac commented Aug 26, 2018

I've given more though to this, and think we should have two different types of File DTOs: one for reading/writing to a file pointer, and one for reading/writing to a byte array. Depending on which one was defined in the model, the results on a read operation would either be written to a temp file (whose path would be available on the object), or into the array.

As discussed in #106, we could also add a hidden field that would store the MD5 hash of the file from the last read/write operation. We could use this hash and compare it to the current value to determine whether the file needs to be updated on an update operation.

abstract class FileDto
{
	internal string LastOperationMD5 { get; set; }
}

class PersistedFile : FileDto
{
	public string FilePath { get; }
	public InMemoryFile StoreInMemory();
}

class InMemoryFile : FileDto
{
	public byte[] ByteArray { get; set; }
	public PersistedFile WriteToFile(string filePath);
}

@mrobustelli mrobustelli added this to the v1.1.0.3 milestone Aug 28, 2018
@mrobustelli
Copy link
Contributor

For now download if part of model...much like single choice field. If do not want to deal with file, do not add to model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants